Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-11-23 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (134 votes), past polls