Oops. Duly noted.
Functions/Subs return lists, not arrays.

But then again, grep() takes a list, and not an array :)

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?)


Sample code to go along with my previous answer:

my $str = 'abc,123,,bob';
my @arr = split ',', $str;
print scalar @arr, " items\n"; # 4
@arr = grep !/^$/, @arr;
print scalar @arr, " items\n"; # 3
@arr = grep !/^$/, split ',', $str;
print scalar @arr, " items\n"; # 3

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to