Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Best way to dynamically use a .pm?

by patcat88 (Deacon)
on Nov 28, 2011 at 19:51 UTC ( #940455=note: print w/replies, xml ) Need Help??

in reply to Best way to dynamically use a .pm?

Read use Module and require. PMs can put their subs in any package. PM names just look like packages, but they aren't, and a PM doesn't have to put subs in the package its named after (a good idea for unmaintainable code). PMs are simply text files given to the do EXPR function.

Note, you can write the require and use functions yourself in pure perl.

I think for your case 1 PM per data format, loaded using requires, or put a begin block read the data header and then do a require in the begin block, parse the file outside of the BEGIN block/normal runtime.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://940455]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2018-07-16 22:21 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (352 votes). Check out past polls.