Re: array question (newbie)
- From: "A. Sinan Unur" <1usa@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 04:04:16 GMT
"Jerry Cloe" <tom@xxxxxxxxxxxxxxxxxxx> wrote in
news:ZM9Re.19164$mb4.2853@xxxxxxxxxxxxxxxxxxxxx:
> Having an array:
>
> @mylist=("apples", "oranges", "bananas");
Easier to type:
my @mylist = qw(apples oranges bananas);
> And refering to a particular element, which syntax is correct? (or
> are both correct)?
>
> print "Item 2 is $mylist[1]\n";
This is correct.
> or
> print "Item 2 is @mylist[1]\n";
That is an array slice, probably not what you intended.
> Both seem to work,
You don't have warnings enabled. Have you read the posting guidelines
for this group yet?
Sinan
--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
.
- Follow-Ups:
- Re: array question (newbie)
- From: John Bokma
- Re: array question (newbie)
- References:
- array question (newbie)
- From: Jerry Cloe
- array question (newbie)
- Prev by Date: Re: array question (newbie)
- Next by Date: Re: Perl match problem
- Previous by thread: Re: array question (newbie)
- Next by thread: Re: array question (newbie)
- Index(es):
Relevant Pages
|