Example 1:
use strict;
use warnings;
sub f {
my $obj = new Module::Debug(1, 2);
}
f();
Running this script gives:
Can't locate object method "new" via package "Module::Debug" (perhaps
you forgot to load "Module::Debug"?) at a.pl line 9.
which is about the right error:
Example 2:
use strict;
use warnings;
sub new {
print "in new\n";
}
sub f {
my $obj = new Module::Debug(1, 2);
}
f();
Running this script gives:
Undefined subroutine &Module::Debug called at a.pl line 9.
Which is just lovely.
If I wrote
my $obj = Module::Debug->new(1, 2);
I would have got the same error,
Can't locate object method "new" via package "Module::Debug" (perhaps
you forgot to load "Module::Debug"?) at a.pl line 9.
regardless of the existence of 'sub new' in the same file.
Gabor
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl