[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-beginners
Subject:    Re: How to prevent split from returning blanks
From:       "Chas. Owens" <chas.owens () gmail ! com>
Date:       2007-10-29 6:43:03
Message-ID: 58ce48dc0710282343p4cd6ebf2v1aa94690c26aef5a () mail ! gmail ! com
[Download RAW message or body]

On 10/28/07, yitzle <yitzle@users.sourceforge.net> wrote:
snip
> Arrays can be set from lists and arrays get converted to lists all the time.
> Is there any practical difference? (Other than the fact that an array
> has a reference which can be passed as a scalar?)
snip

There are several key differences and it is always important to know
what you are dealing with.  For instance, an array in scalar context
yields the number of elements it contains, but a list yields the last
item.  Take this code for example:

#!/usr/bin/perl

use strict;
use warnings;

sub foo { return qw<a b c d> };
my $scalar = foo();
print "$scalar\n";

If foo returned an array then $scalar would be 4, but since function
returns are lists it is d.

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic