I want to be able to ensure a set of variables will all have values before assigning them to @_
But that's not what you're doing here. You're checking that the values in @_ are defined before assigning them to your local variables using a horribly complex statement.
Do you have to know the variable name? Wouldn't the parameter number be enough to track down any problems? I'd probably wrtie it something like this:
use strict; sub file_name { die "incorrect number of parameters\n" unless @_ == 4; for each (0 .. $#_) { die "invalid parameter [$_]\n" unless defined $_[$_]; $" = ''; "I@_"' }
Oh, and the commas in your qw are probably a bug too.
--
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
In reply to Re: Maintaining strict refs while Binding a set of variables to @_ or dying if they are not defined
by davorg
in thread Maintaining strict refs while Binding a set of variables to @_ or dying if they are not defined
by princepawn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |