Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Conditional inheritance strategy

by ikegami (Patriarch)
on Oct 27, 2010 at 16:36 UTC ( [id://867779]=note: print w/replies, xml ) Need Help??


in reply to Conditional inheritance strategy

Don't have My inherit from My::XML and My::JSON, have My::XML and My::JSON inherit from My.

I'm guessing you want to do this since you get a file name and you want to load the file using the right module.

package My; sub load { my ($class, %args) = @_; my $file_type = ...; if ($file_type eq 'xml') { require My::XML; return My::XML->new(%args); } elsif ($file_type eq 'json') { require My::JSON; return My::JSON->new(%args); } } sub new { ... } sub method1 { ... } sub method2 { ... }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2025-05-23 20:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.