This is going to be a head-slapper, I know, but it's late and my brain hurts... I've got a script that has a sub that accepts a hash of arguments, one of which happens to be an array. If I pass the array as a reference, everything works fine.

Now for the head slapping part, how do I handle things INSIDE the sub so I don't have to pass the array as a reference?  Code and desired output are below.

Thanks,

Deane

use strict;
use warnings;

sub do_smthng{
my %args = ( -s1 => undef,
             -s2 => undef,
             -ar => undef,
             @_
           );

   print "    s1: $args{-s1}\n";
   print "    s2: $args{-s2}\n";
   print "ary[0]: $args{-ar}->[0]\n";
   print "ary[1]: $args{-ar}->[1]\n";
   print "ary[2]: $args{-ar}->[2]\n";
}


my @arg_ary = ( 'alpha', 'bravo', 'charlie' );

do_smthng( -s1 => 42,
           -s2 => 96,
           -ar => [EMAIL PROTECTED] ); # I wanna lose the "\" here


Desired output:
    s1: 42
    s2: 96
ary[0]: alpha
ary[1]: bravo
ary[2]: charlie
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to