Re: array question (newbie)
- From: Simon Taylor <simon@xxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 13:58:48 +1000
Hello Jerry, :
Having an array:
@mylist=("apples", "oranges", "bananas");
And refering to a particular element, which syntax is correct? (or are both correct)?
print "Item 2 is $mylist[1]\n"; or print "Item 2 is @mylist[1]\n";
Both seem to work, and looking at other code, I see it done both ways.
The first is a scalar value, the second is an array slice.
This is a frequently asked question. So you can use the "-q" option of the perldoc command to dig it up:
Run:
perldoc -q array
and look for the section:
"What is the difference between $array[1] and @array[1]?"
Regards,
Simon Taylor -- www.perlmeme.org .
- References:
- array question (newbie)
- From: Jerry Cloe
- array question (newbie)
- Prev by Date: array question (newbie)
- Next by Date: FAQ 1.15 Where can I get a list of Larry Wall witticisms?
- Previous by thread: array question (newbie)
- Next by thread: Re: array question (newbie)
- Index(es):
Relevant Pages
|
|