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 an array?

    my $number_key;
    foreach my $key (keys %hash) {
        if ($key =~ /^\d/) {
            $number_key = $key;
            last;
        }
    }


It might be a better idea to keep the key's name around in a seperate
variable, at the point where you put it in the hash, instead of searching
the hash after the fact.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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

Reply via email to