Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
then in another piece of code:package gen_var; use base 'Exporter'; my @exported_symbols; my @variables = qw(one two three); my $counter = 1; our @EXPORT_OK; foreach my $variable (@variables) { eval "our \$$variable = $counter; push \@exported_symbols, \$$varia +ble"; $counter++; } my $export_vars = join(', ', @exported_symbols); eval "\@EXPORT_OK = ($export_vars)"; 1;
I realise some purists may bristle at this kind of code, but now that I've had a crack at writing it, I'm interested in finding out how to get it to workuse gen_var($one); print $one;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Importing dynamic variables
by davido (Cardinal) on Nov 16, 2006 at 23:29 UTC | |
by Anonymous Monk on Nov 17, 2006 at 00:06 UTC | |
by Anonymous Monk on Nov 17, 2006 at 00:30 UTC | |
by Anonymous Monk on Nov 17, 2006 at 01:46 UTC | |
by BUU (Prior) on Nov 17, 2006 at 02:31 UTC | |
|
Re: Importing dynamic variables
by gellyfish (Monsignor) on Nov 17, 2006 at 10:24 UTC | |
by Anonymous Monk on Nov 18, 2006 at 22:21 UTC |