bkv2k has asked for the wisdom of the Perl Monks concerning the following question:
In a separate file: (my_test.pl)package MyTest; use warnings; use strict; sub new { my ($class) = @_; $class = ref( $class ) || $class; my $self = {}; bless( $self, $class ); return $self; } sub display { my ($self) = @_; print "\nWow! It worked.\n\n"; } sub test { my ($self) = @_; display(); } return 1;
Shouldn't this havd crashed when display() is called in sub test() instead of $self->display()?#!/usr/bin/perl use warnings; use strict; use MyTest; my $tst = MyTest->new(); $tst->test();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Object Method Call
by moritz (Cardinal) on Jul 26, 2009 at 16:45 UTC | |
|
Re: Object Method Call
by dreadpiratepeter (Priest) on Jul 26, 2009 at 16:48 UTC | |
by AnomalousMonk (Archbishop) on Jul 26, 2009 at 17:39 UTC | |
by Bloodnok (Vicar) on Jul 26, 2009 at 23:53 UTC | |
by bkv2k (Novice) on Jul 26, 2009 at 17:44 UTC | |
by afoken (Chancellor) on Jul 27, 2009 at 12:06 UTC | |
by ikegami (Patriarch) on Jul 27, 2009 at 19:40 UTC | |
by afoken (Chancellor) on Jul 27, 2009 at 19:54 UTC | |
by AnomalousMonk (Archbishop) on Jul 27, 2009 at 14:56 UTC | |
by afoken (Chancellor) on Jul 27, 2009 at 19:33 UTC | |
| |
|
Re: Object Method Call
by ikegami (Patriarch) on Jul 27, 2009 at 00:23 UTC |