http://www.perlmonks.org?node_id=942218


in reply to help required for regexp

Nobody seems to have posted a complete solution that actually works.

use strict; use warnings; my %Hidlabels = ( '3333' => 1, '4444' => 2, '2222' => 3 ); my $str = 'f3333_4444_2222'; $str =~ s/f(\d+)/$Hidlabels{$1}/g; print $str;

Replies are listed 'Best First'.
Re^2: help required for regexp
by choroba (Cardinal) on Dec 07, 2011 at 11:27 UTC
    Nobody seems to have posted a complete solution that actually works.
    Neither did you.
    Update: Eliya's solution seems to work.
      Odd, I could have sworn I read all the posts on the way by. If not, then I apologize for posting essentially a duplicate solution. However, mine does in fact work if you run it, so you're wrong on that.