hsmyers has asked for the wisdom of the Perl Monks concerning the following question:
Is there an equilvalent way to code the following for 'my' variables?:
#!/perl/bin/perl # # test.pl -- use strict; use warnings; use diagnostics; our $a = 'var a'; our $b = 'var b'; varprint('a','b'); sub varprint { my @list; for (@_) { my $var = $_; my $ref = $main::{$var}; push(@list, "\$$var='$$ref'"); } print join(", ",@list),"\n"; }
--hsm
"Never try to teach a pig to sing...it wastes your time and it annoys the pig."
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: 'my' and %main::
by adrianh (Chancellor) on Feb 10, 2003 at 17:32 UTC | |
by hsmyers (Canon) on Feb 10, 2003 at 18:05 UTC | |
Re: 'my' and %main::
by MZSanford (Curate) on Feb 10, 2003 at 19:02 UTC | |
Re: 'my' and %main::
by hsmyers (Canon) on Feb 10, 2003 at 18:17 UTC |