>>>>> "Peter" == Peter Farrar <[EMAIL PROTECTED]> writes:

Peter> Hi All,
Peter> I'm passing a hash to a subroutine like this:
Peter>       subname("a" => 123, "b" =>"fff", "C" => "joyjoyjoy");

Peter> On the receiving side I want all keys to be upper case.  I can map like
Peter> this:
Peter>       sub subname{
Peter>             map {$_ =~ tr/a-z/A-Z/} @_;
Peter>             my %values = @_;
Peter>             ..
Peter>       }

First, please don't use map in a void context for its side effects.

Peter> and I can live with that I guess.  But really I just want to push the keys,
Peter> not the values, into upper case.

Peter> Is there a way to just map the keys?  I can't think of one.

Just loop it:

    sub subname {
      my %values;
      while (@_ >= 2) {
        my ($key, $value) = splice @_, 0, 2;
        $values{uc $key} = $value;
      }
      ...
    }

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to