On 31 Jan 2004, at 21:40, John W. Krahn wrote:
Jan Eden wrote:Nice, however, for those Learning Perl, it would be nice to have a simple description first, it is difficult to understand the perldoc definition if you don't know the basic difference to start with.
Nilay Puri, Noida wrote:
Can any one walk me thru this piece of code ::
while(<STDIN>) { chomp ; $isbn =(split(/^_/, $_))[0] ; --- not able to understand what is being accessed (......)[0]
That's the first element of the array returned by split^^^^^^^^^^^^^^^^^^^^^^^^^^^ Functions/subroutines in perl return a LIST, not an array.
perldoc -q "What is the difference between a list and an array"
From Learning Perl 2's:
A list is ordered scalar data # (one, two, three, four)
An array is a variable that holds a list # @array = (one, two, three, four);
Each element of the array is a separate scalar variable with an independent scalar value # $array[1] is two
These values are ordered # $array[0] $array[1] ....2 .. 3.
And of course once you've read that, you can do: perldoc -q "What is the difference between a list and an array"
With the Perl heavyweights on this list it is sometimes easy to forget that so many are LEARNING Perl and for most of us, we are always Learning Perl.
Cheers,
Jerry
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>