The stupid question is the question not asked | |
PerlMonks |
Match text in file with array and substitute array position ?by Anonymous Monk |
on Nov 29, 2002 at 17:30 UTC ( [id://216566]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks, I have an array holding codes like ABC, DEF, GHT etc. I want to look through a text file and replace any matches to the array codes with the position that code holds in the array. ie. so if my codes are $code[0]=ABC and $code[1]=DEF and the file contains the text ABC and DEF it gets replaced with the numbers 0 and 1 instead. I have tried this: Which doesn't work. I'm probably trying something really dumb, but I hoped the substitution might be able to work like that. Any ideas on better methods ? Thanks a lot, anon
Back to
Seekers of Perl Wisdom
|
|