Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Conditional inheritance strategy

by ikegami (Pope)
on Oct 27, 2010 at 16:36 UTC ( #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
Node Status?
node history
Node Type: note [id://867779]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2020-12-02 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (40 votes). Check out past polls.

    Notices?