In addition to toolic's suggestions, you could try Smart::Comments. If you're feeling adventurous, you could even use symbolic references. In general, not a great habit to get into, but for some tasks like this, they're not so bad.
$ cat t.pl #!/usr/bin/perl # Prevent symbolic references, etc. in general use strict; use warnings; # Use our instead of my to ensure that the value is accessible our $boom = 'Kaboom!'; our $bam = 'Kerblam!'; + # Unfortunately, the call looks odd... say_var('boom'); say_var('bam'); sub say_var { # Turn off strict for now no strict; my $t = shift; print "\$$t = >$$t<\n"; } $ perl t.pl $boom = >Kaboom!< $bam = >Kerblam!<
.... somehow I feel that I'll be roasted for suggesting such a thing ....
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: How to retrieve the name of a variable ?
by roboticus
in thread How to retrieve the name of a variable ?
by mascip
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |