my %F = (a=>1, b=>2, c=>3); my @F = qw(a 1 b 2 c 3); foo(%F); foo(@F);
Within each code block both calls to foo pass the same values; @_(the parameters list) will be the same. NOTE: It is luck that the first works, as it relies upon the particular key/value pairs and how the current implementation of hashes in perl works.#New simpler code to avoid slices my %F = (a=>1); my @F = qw(a 1); foo(%F); foo(@F);
Basically an array is an actual thing that lives somewhere and has an address (you can get a glob for it, you can use a reference to it), but that is not so for a list.
UPDATE: Modified code to ensure hash order prompted by dmmiller2k's reply. Which of course makes the comparison a little less clear since it uses slices. Added a second code block to reclarify
UPDATE I am an idiot. The sliced version only returned the values. And it did in fact work as advertised to begin with. It was just lucky that it did so. Added the NOTE, I really do understand this, but apparently I'm not very good at explaining it with code ;-)
perl -p -e "s/(?:\w);([st])/'\$1/mg"