in reply to Match text in file with array and substitute array position ?
my %codes = ( ABC => 0, DEF => 1, GHT => 2 ); my $alternation = join('|', keys %codes); my $substitution = qr/($alternation)/; while (<DATA>) { s/$substitution/$codes{ $1 }/g; print; }
Untested, but it can't be too far wrong.
|
|---|