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

Re: [ID 20000317.003] missing slice of reference

From:
JVromans
Date:
March 17, 2000 04:51
Subject:
Re: [ID 20000317.003] missing slice of reference
Message ID:
m2snxp3hbf.fsf@phoenix.squirrel.nl
Mark Overmeer <markov@ATComputing.nl> 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];
__END__

-- Johan



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About