Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Writing a Perl module that dynamically loads other modules

by stephen (Priest)
on Mar 01, 2013 at 20:17 UTC ( [id://1021330]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # up at the top:
    use My::Format::Foo;
    ...
          my $parser_class = 'My::Format::' . ucfirst $self->{'FILETYPE'};
          my $data = $parser_class->parse($_);
    
  2. or download this
    # Up top
    use Module::Load;
    ...
    my $module_name = 'My::Format::' . ucfirst $self->{'FILETYPE'};
    load $module_name;
    my $data = $module_name->parse($_);
    
  3. or download this
    my $module_filename = 'My/Format/' . ucfirst($self->{'FILETYPE'}) . '.
    +pm';
    require $module_filename;
    my $module_classname = 'My::Format::' . ucfirst($self->{'FILETYPE'};
    $module_classname->import();
    my $data = $module_classname->parse($_);
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-25 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found