in reply to Basic Perl passing a temp array
I would go the other route. Rather than making your caller create an array reference, have your subroutine do it:
sub addHost { my $host = shift; print "$host\n"; $getSSO{$host} = [ @_ ]; } # now this will work as is addHost('aklia700', qw(carrot lunch)); # and it's also slightly simpler when you have a named array my @a = qw(carrot lunch); addHost('aklia700', @a);
Update: fixed bug in subroutine. Old code was shifting after the anonymous array had been constructed.
|
|---|