Re: returning arrays

2014-09-09 Thread Paul Johnson
On Tue, Sep 09, 2014 at 03:12:00PM -0700, Jim Gibson wrote: > > On Sep 9, 2014, at 2:57 PM, Shawn H Corey wrote: > > > On Tue, 09 Sep 2014 23:09:52 +0200 > > lee wrote: > > > >> my $i = 1; > >> my $f = 2.5; > >> my $s = 'string'; > >> my $list = (1, 2, 3); > > > > No, the count of items in the

Re: returning arrays

2014-09-09 Thread Shawn H Corey
On Tue, 9 Sep 2014 15:05:58 -0700 Jim Gibson wrote: > Some people make a distinction between 'list' and 'array'. A list is > a sequence of scalar values indexed by an integer. An array is a > variable whose value is a list (or something like that -- I don't > really distinguish the two myself.)

Re: returning arrays

2014-09-09 Thread Uri Guttman
On 09/09/2014 06:01 PM, John SJ Anderson wrote: On Tue, Sep 9, 2014 at 2:57 PM, Shawn H Corey wrote: Lists are sequences used by Perl. They are very short lived, seldom longer than one statement. The way I've always liked to explain this is that arrays are the containers you use to store a li

Re: returning arrays

2014-09-09 Thread Jim Gibson
On Sep 9, 2014, at 2:57 PM, Shawn H Corey wrote: > On Tue, 09 Sep 2014 23:09:52 +0200 > lee wrote: > >> my $i = 1; >> my $f = 2.5; >> my $s = 'string'; >> my $list = (1, 2, 3); > > No, the count of items in the list gets stored in $list: $list == 3 Unless the thing on the right-hand-side of t

Re: returning arrays

2014-09-09 Thread Jim Gibson
On Sep 9, 2014, at 2:09 PM, lee wrote: > Jim Gibson writes: > >> On Sep 8, 2014, at 3:13 PM, lee wrote: >> >>> Shawn H Corey writes: >>> On Mon, 18 Aug 2014 16:17:53 +0800 # or sub myfunc { return [ 1, 2, 3 ]; } >>> >>> Is there a difference to >>> >>> sub my

Re: returning arrays

2014-09-09 Thread John SJ Anderson
On Tue, Sep 9, 2014 at 2:57 PM, Shawn H Corey wrote: > Lists are sequences used by Perl. They are very short lived, seldom > longer than one statement. The way I've always liked to explain this is that arrays are the containers you use to store a list. As Shawn says, a list is usually pretty ep

Re: returning arrays

2014-09-09 Thread Shawn H Corey
On Tue, 09 Sep 2014 23:09:52 +0200 lee wrote: > my $i = 1; > my $f = 2.5; > my $s = 'string'; > my $list = (1, 2, 3); No, the count of items in the list gets stored in $list: $list == 3 > my $list_reference = [(1, 2, 3)]; > my $dereferenced_list = $@list_reference; my @dereferenced_list = @$li

Re: returning arrays

2014-09-09 Thread lee
Jim Gibson writes: > On Sep 8, 2014, at 3:13 PM, lee wrote: > >> Shawn H Corey writes: >> >>> On Mon, 18 Aug 2014 16:17:53 +0800 >>> # or >>> >>> sub myfunc { >>> return [ 1, 2, 3 ]; >>> } >> >> Is there a difference to >> >> sub myfunc { >> return ( 1, 2, 3 ); >> } > > The first example r