Marshall's advice can also be applied to when the OP wants to pass multiple arg hashes they can be passed as refs and looped over (avoiding the nasty splitting of args!):
#!usr/bin/perl -w ## shamelessly copied from Marshall use strict; use Data::Dumpe qw/Dumper/; ## pass two anon hash refs to the sub Some_subroutine( { 'NAME' => 'name222', 'COLOR' => 'yellow', 'SIZE' => 'big', }, { 'NAME' => 'name444', 'COLOR' => 'yellow444', 'SIZE' => 'big444', }, ); sub Some_subroutine { ## collect the refs passed to the sub my @list = @_; ## just to see what we got print Dumper \@list; ## loop through each ref passed and process as before for my $ref (@list){ foreach my $key (keys %$ref) { print "key $key \tvalue is $ref->{$key}\n"; } } }
In reply to Re^2: passing string to sub and string split
by BioLion
in thread passing string to sub and string split
by courierb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |