That works because you're not using strict and Perl is treating $#self->{op_stack} as if $self is an array reference. With strict, you would have been told that "Global symbol @self" requires an explicit package name at ...". That should have given you the information that you need to tweak the script a little.
$#{ $self->{ op_stack } }
This snippet will show you more:
package Foo; use strict; sub new { my $class = shift; my $stuff = { a => [ qw/ Ovid is a schmuck / ] }; bless $stuff, $class; return $stuff; } package main; use base "Foo"; my $test = Foo->new; use Data::Dumper; print Dumper $test; print $#{$test->{a}};
That prints '3', like it should.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In reply to (Ovid) Re: Special characters in array
by Ovid
in thread Special characters in array
by vladb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |