On Aug 13, Birgit Kellner said:

>Hm, what's the shortest way to do this: I have a hash where one, and only 
>one, key begins with a number, I don't know its value and want to assign 
>this value to a variable.

Loop over the keys, using keys() or each().

  for (keys %hash) {
    $wanted = $hash{$_}, last if /^\d/;
  }

or

  while (my ($k, $v) = each %hash) {
    $wanted = $v, last if $k =~ /^\d/;
  }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


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

Reply via email to