<?xml version="1.0" encoding="windows-1252"?>
<node id="847531" title="Re: How to create dynamic global variables" created="2010-07-01 10:44:22" updated="2010-07-01 10:44:22">
<type id="11">
note</type>
<author id="590906">
linuxer</author>
<data>
<field name="doctext">
&lt;p&gt;I have problems to completely understand your request; I hope my guess will be helpful to you.&lt;/p&gt;

&lt;p&gt;You could use a global hash which uses the module's name as key and the object as value.&lt;/p&gt;

&lt;c&gt;#! /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-&gt;new; 1;" or die "eval failed: $@\n";
}

print Dumper \%object;

&lt;/c&gt;
</field>
<field name="root_node">
847508</field>
<field name="parent_node">
847508</field>
</data>
</node>
