develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [ID 20000317.003] missing slice of reference

March 17, 2000 04:51
Re: [ID 20000317.003] missing slice of reference
Message ID:
Mark Overmeer <> writes:

>    print '@y->[1,2] : ', @y->[1,2],"\n";   #doesn't work.

It is even worse. The following program compiles and runs with only
one warning: that @a[2] should be written as $a[2]. @a->[2] is
accepted, without complaint, to apparently mean $a[2]. And I cannot
see why 'scalar(@x)->[2]' produces the 3rd element of array @x.
It should produce a fatal Can't use string ("4") as an ARRAY ref while
"strict refs" in use.

#!/usr/bin/perl -wl
use strict;
my @x = qw(a b c d);
print '$x[2] = ', $x[2];
print '@x[2] = ', @x[2];
print '@x->[2] = ', @x->[2];
print 'scalar(@x)->[2] = ', scalar(@x)->[2];

-- Johan Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About