Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: reading file into an array

by McDarren (Abbot)
on Dec 05, 2008 at 21:52 UTC ( #728396=note: print w/ replies, xml ) Need Help??


in reply to Re^2: reading file into an array
in thread reading file into an array

$# (not #$) refers to the index of the last element of an array.

The "at-sign" sigil (@) is used when you refer to two or more elements of an array. If you are accessing (or referring to) a single element of an array, then the "dollar-sign" ($) sigil is used.

For example:

my @foo = qw/a b c/; print "$foo[1]\n"; # Prints b print "@foo\n"; # Prints a b c print "$foo[$#foo]\n"; # Prints c (but you would probably never do th +is) print "$foo[-1]\n"; # Also prints c (a better way than the previou +s) print "@foo[0,2]\n"; # Prints a c

Cheers,
Darren :)


Comment on Re^3: reading file into an array
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://728396]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-09-03 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls