Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How to create dynamic global variables

by linuxer (Deacon)
on Jul 01, 2010 at 14:44 UTC ( #847531=note: print w/ replies, xml ) Need Help??


in reply to How to create dynamic global variables

I have problems to completely understand your request; I hope my guess will be helpful to you.

You could use a global hash which uses the module's name as key and the object as value.

#! /opt/perl/bin/perl # vim: set ts=4 sw=4 sts=4 et nu: use strict; use warnings; use Data::Dumper; my %object; my @modules = qw( CGI ); for my $mod ( @modules ) { eval "use $mod; \$object{$mod} = $mod->new; 1;" or die "eval faile +d: $@\n"; } print Dumper \%object;


Comment on Re: How to create dynamic global variables
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (15)
As of 2015-07-31 21:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls