RE: finding a key in a hash with regexp

2001-08-14 Thread Faux, David
ROTECTED]] Sent: 13 August 2001 00:15 To: Birgit Kellner Cc: [EMAIL PROTECTED] Subject: Re: finding a key in a hash with regexp At 18:25 2001.08.12, Birgit Kellner wrote: >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 kno

Re: finding a key in a hash with regexp

2001-08-12 Thread Michael Fowler
On Mon, Aug 13, 2001 at 12:25:32AM +0200, Birgit Kellner wrote: > foreach my $key(keys %hash) { > if ($key =~ /^\d/) {push (@keys, $key); } > } > > But since I know there will only be one key where this condition is true, > looping and creating an array seems like a waste. Then why create

Re: finding a key in a hash with regexp

2001-08-12 Thread Jeff 'japhy/Marillion' Pinyan
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{

Re: finding a key in a hash with regexp

2001-08-12 Thread Eric Beaudoin
At 18:25 2001.08.12, Birgit Kellner wrote: >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. > >If I were to do a foreach loop, I'd do this (presuming that %hash is alrea