in reply to Regexs on Hash Keys
%fdat = ( 'redirect_sam' => 'boondoggle' ); $fdat{$_} = $fdat{"redirect_$_"} for map /^redirect_(.*)$/, keys %fdat;
Or, alternately:
for(keys %fdat) { $fdat{$1} = $fdat{$_} if /^redirect_(.*)$/; }
Don't know if you'll gain any speed from it, though. Please note, I used map instead of grep for the first snippet because I just wanted to return the matched part, not the entire list element as grep does.
HTH
'kaboo
Update:
Sigh... too slow... I like merlyn's tho, it's purtee.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Regexs on Hash Keys
by tye (Sage) on Dec 01, 2000 at 03:01 UTC |