in reply to Getting pair of values from an array

Your second example is on track: treat @_ as a hash.

sub newfoo { my %hash = @_; foreach (keys %hash) {print "$_: $hash{$_}\n";} }

When you use an array as a hash, it is automatically broken up into key, value pairs.

http://www.nodewarrior.org/chris/

Replies are listed 'Best First'.
Re(2): Getting pair of values from an array
by dmmiller2k (Chaplain) on Dec 27, 2001 at 19:57 UTC
    ...treat @_ as a hash.

    You are not TREATING the array as a hash, but in fact COPYING its contents into one. As noted elsewhere by Screamer, using a hash ignores the potential data loss of duplicate keys in the data. splice() is the way to go.

    dmm

    You can give a man a fish and feed him for a day ...
    Or, you can
    teach him to fish and feed him for a lifetime