ant has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
,
I have wrote the code below in OO programming style, and am trying to get the box printed! But my referencing the hash is incorrect, and I've read several tutorials but still seem to fail to print the box.
Any help gratefully recieved.
Ant
in main.pl
,
I have wrote the code below in OO programming style, and am trying to get the box printed! But my referencing the hash is incorrect, and I've read several tutorials but still seem to fail to print the box.
Any help gratefully recieved.
Ant
in main.pl
In shapes.pmuse shapes; my %box; $box{line1} = ' ---'; $box{line2} = '| |'; $box{line3} = ' ---'; my $box = shapes->new(shape => %box); exit();
package shapes; #constructor sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = { shape => {}, }; return bless $self, $class; } sub print_shape { my $self = shift; print $self->{shape}{line1} . "\n"; } 1
Janitored by Arunbear - retitled from 'box trouble?!'
Back to
Seekers of Perl Wisdom