pileofrogs has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way to find the name of a variable?
For example, I'm checking the args to a function like this:
sub blah { my ($foo,$bar,$baz) = @_; for my $arg (\$foo,\$bar,\$baz) { if ( !defined($$arg) ) { croak "You forgot something!\n"; } } ... }
It would be nice to be able to say "You forgot foo!" if $foo was undefined. I know there are other ways to solve the actual problem, but I'm curious if there is a way to know the name of a variable.
--Thanks!
Pileofrogs
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Can you find the name of a variable?
by ikegami (Patriarch) on Nov 13, 2009 at 19:18 UTC | |
by JadeNB (Chaplain) on Nov 15, 2009 at 07:51 UTC | |
by ikegami (Patriarch) on Nov 15, 2009 at 08:44 UTC | |
Re: Can you find the name of a variable?
by chromatic (Archbishop) on Nov 13, 2009 at 19:25 UTC | |
Re: Can you find the name of a variable?
by afoken (Chancellor) on Nov 14, 2009 at 10:57 UTC | |
Re: Can you find the name of a variable?
by ambrus (Abbot) on Nov 15, 2009 at 11:07 UTC |
Back to
Seekers of Perl Wisdom