in reply to Re: Maintaining strict refs while Binding a set of variables to @_ or dying if they are not defined
in thread Maintaining strict refs while Binding a set of variables to @_ or dying if they are not defined

It'd be easier if you reply to my message, so I don't have to search for a response. ;)

Anyway, this code works for me:
#!/usr/bin/perl -w use strict; sub someFunc { my $args = [ { client_number => 1, MM => 2, DD => 3, S => 4, }, ]; for (keys %$args) { my $idx = $args->[0]{$_} - 1; if (defined $_[$idx]) { $args->{$_} = $_[$idx], next } die "$_ not defined"; } print "@$args\n"; } someFunc(1,2,3,4); # fine someFunc(1,2,3); # 'S' is not defined
It works under strict.

japhy -- Perl and Regex Hacker
  • Comment on Re: Re: Maintaining strict refs while Binding a set of variables to @_ or dying if they are not defined
  • Download Code