in reply to Want to get regexp list from file
Thanks a bunch for everyones comments. Really appreciate it. Here is what I am going to use: The Ascii.txt looks something like this:
Then the user supplied the mapping file"X[6]" + "XM7" + "Z_data[17]" + "Z[18][20]"
Then my perl script looked like this:X[6] X_6_ XM7 X_7_ Z_data[17] Z_17_ Z[18][20] Z_18__20_
#use strict; #use warnings; $regexp = table2; $i =0; open RE, $regexp; while (<RE>) { chop; ($search[$i], $replace[$i]) = split(/ /, $_ ); $search[$i] =~ s/\[/\\[/g; $search[$i] =~ s/\]/\\]/g; $i++; } while (<>) { for($i=0; $i < $#search; $i++) { s{$search[$i]}{$replace[$i]}g; } print; }
|
|---|