princepawn has asked for the wisdom of the Perl Monks concerning the following question:
I want to be able to ensure a set of variables will all have values before assigning them to @_
The following code works, but I would like
use strict; sub file_name { my ($client_number, $MM, $DD, $S); my @word = qw($client_number, $MM, $DD, $S); no strict 'refs'; !defined($_[$_]) and die "$word[$_] not defined" or ${$word[$_]} = $_[$_] for (0..$#_); "I$client_number$MM$DD$S"; } file_name 1,2,3,4;
|
|---|