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

Re: Best way to dynamically use a .pm?

by Tux (Canon)
on Nov 29, 2011 at 14:42 UTC ( [id://940637]=note: print w/replies, xml ) Need Help??


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

Why put the data in .pm files? Can't it be controlled by data structures in some readable way, like JSON or YAML? Does it need to include code? If parameters in the config files can control program flow in the module, I'd say stick to config files and not dynamic modules. An alternative to JSON of YAML might be to look at any of the plethora of Config:: modules on CPAN.

Then there is the long forgotten support for files in the do keyword:

$ cat honda.pl #!perl print STDERR "Using Honda\n"; sub honda { print "Honda rulez\n"; } 1; $ perl -wE'do "honda.pl";say 2;honda()' Using Honda 2 Honda rulez $

do does accept variables :)


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: Best way to dynamically use a .pm?
by TJPride (Pilgrim) on Nov 29, 2011 at 19:49 UTC
    Queries, templates, and the data interface between the two can vary widely between dealers, with no way to predict in advance. The best way to handle this is custom-modified subs, as far as I can tell. Essentially, the same .pm only in many different flavors. Maybe this isn't the best approach, but it seems to be working - I was only really concerned with efficiency, now that it'll have to be done for large numbers of transactions rather than just a few data imports.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-23 14:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found