use strict; use warnings; foo( "hi", "apoinv", "slkjhfp", "876", "poi", "asdf", "sdf", "there" ); print "\n"; foo( { flags => "hi", img => "apoinv", name => "slkjhfp", big => "876", gallery => "poi", page => "asdf", caption => "sdf", num => "there" }); sub foo { my %args; if (ref $_[0] eq "HASH") { %args = %{$_[0]}; } else { @args{qw(flags img name big gallery page caption num)} = @_; } print "$_:\t$args{$_}\n" for sort keys %args; } #### big: 876 caption: sdf flags: hi gallery: poi img: apoinv name: slkjhfp num: there page: asdf big: 876 caption: sdf flags: hi gallery: poi img: apoinv name: slkjhfp num: there page: asdf