Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: OO Perl: Nested classes question

by mreece (Friar)
on Sep 08, 2006 at 23:09 UTC ( [id://572099]=note: print w/replies, xml ) Need Help??


in reply to Re^2: OO Perl: Nested classes question
in thread OO Perl: Nested classes question

Also I note that your "preferred way to call constructors" comment is just cargo culting unless you can give some concrete reasons why that is preferred.
(of course you know this but) fear of imported subroutines is one reason ..

# Stuff.pm package Stuff; use base 'Exporter'; @EXPORT = qw(new); sub new { print "this is exported new!\n" }
# new.pl use Stuff; my $foo = Foo->new; # this works $foo->baz; my $bar = new Foo; # this doesn't $bar->baz; package Foo; sub new { my $class = shift; print "constructing a $class\n"; bless {}, $class; } sub baz { my $self = shift; print "hello from a ", ref $self, "\n"; }
% perl new.pl
constructing foo
hello from a Foo
this is exported new!
Can't call method "baz" without a package or object reference at new.pl line 9.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://572099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found