On Jul 10, bob ackerman said:
>you get a warning with @x[2] if 'x' is an array,
>but no warning with @$x[2] where 'x' is an array ref.
>so perl isn't handling quite the same.
Well, let me refer to the source. toke.c is where the "scalar value @x[1]
better written as $x[1]" comes from. To raise that warning, though, Perl
must find an identifier after the '@'. An identifier is something simple
like 'foo' or '_' or 'bar_123'.
Something that is NOT an identifier is '$x', which is why
@$x[1]
does not raise the warning.
In addition, look at this:
sub foo { return (1,2) }
@x = qw( this is weird );
print "@x[foo]"; # yields the warning
print "@x[+foo]"; # yields the warning
print "@x[&foo]"; # does not
print "@x[foo()]"; # does not
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]