#!/usr/bin/perl use strict; sub foo { my ( $flags, $img, $name, $big, $gallery, $page, $caption, $num ); my $opts = shift; if (ref $opts eq "HASH") { print "using hash...\n"; no strict; for (qw( flags img name big gallery page caption num ) ) { $$_ = $opts->{$_}; print "\tsetting $_ to $$_ ($opts->{$_})\n"; } use strict; } else { print "using args...\n"; $flags = $opts; # these vars are local for some reason... ??? ( $img, $name, $big, $gallery, $page, $caption, $num ) = @_; print "flags = $flags, img = $img\n"; # they're getting set... # but their values are now going to vanish... } print "reviewing what's been set...\n"; no strict; for (qw( flags img name big gallery page caption num ) ) { print "\t$_ = $$_\n"; } use strict; } # it doesn't matter which order you call these functions... foo( "hi", "apoinv", "slkjhfp", "876", "poi", "asdf", "sdf", "there" ); foo( { flags => "hi", img => "apoinv", name => "slkjhfp", big => "876", gallery => "poi", page => "asdf", caption => "sdf", num => "there" });