Re: array question (newbie)



Jerry Cloe wrote:
> 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.

Put the statement:

use warnings;

at the top of your program and perl will tell you which is correct.


John
--
use Perl;
program
fulfillment
.



Relevant Pages

  • Re: Vaporware: metaduel simulator
    ... (Neither Perl nor Python ... Perl loses on syntax, ... Python on internal implementation.) ... an array twice. ...
    (rec.games.roguelike.development)
  • Re: FAQ 4.41 How can I remove duplicate elements from a list or array?
    ... I can't quite make out this syntax. ... in the hash), the grep will see the result as logic "true"; ... then added to the array. ... primitive in Perl? ...
    (comp.lang.perl.misc)
  • Re: FAQ 4.41 How can I remove duplicate elements from a list or array?
    ... I can't quite make out this syntax. ... in the hash), the grep will see the result as logic "true"; ... then added to the array. ... The fault is that Perl hash is heavily wieghted with the underlying ...
    (comp.lang.perl.misc)
  • array question (newbie)
    ... Having an array: ... And refering to a particular element, which syntax is correct? ... Prev by Date: ...
    (comp.lang.perl.misc)
  • Re: Learning Perl
    ... it should be an array, ... Then they'd be completely inaccessible to beginners. ... that should be my $var. ... so why is it redundant to point out that Perl is different from C here? ...
    (comp.lang.perl.misc)