in reply to How to I retrieve a specific key/value from a hash?

You can create variable with names based on strings via the following mechanism:
${ $graphic.$i } = $pers_dcr_files{ $key[$i] }{GraphicName};

Replies are listed 'Best First'.
Re: Re: How to I retrieve a specific key/value from a hash?
by no_slogan (Deacon) on May 15, 2001 at 21:34 UTC
    I was just reading an excellent article by Dominus on why you shouldn't do that. Since you only have two variables, it's not going to hurt you to flatten that loop:
    $graphic1 = $pers_dcr_files{ $key[1] }{GraphicName}; $graphic2 = $pers_dcr_files{ $key[2] }{GraphicName};
    Probably run faster and be easier to maintain that way, too. If you need more variables, use a hash:
    for $i (1..10) { $graphic{$i} = $pers_dcr_files{ $key[$i] }{GraphicName}; }
    You have to reference it as $graphic{1} instead of $graphic1, but that doesn't seem like a real big problem.