in reply to modifying a file with regex!
this should work, but it may not.#!/usr/bin/perl -w -i.bak $regexfile = shift @argv; open (FH, $regexfile); @regexen = <FH>; close FH; while (<>) { foreach $regex (@regexen) { ($a, $b) = split /\t/, $regex; s/$a/$b/og; } }
Original code restored below by GrandFather
#!/usr/bin/perl -w $regexfile = shift @argv; open (FH, $regexfile); @regexen = <FH>; close FH; while (<>) { foreach $regex (@regexen) { $regex; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: modifying a file with regex!
by aaron_baugher (Curate) on Mar 17, 2012 at 19:32 UTC | |
by linuxkid (Sexton) on Mar 17, 2012 at 21:31 UTC | |
by choroba (Cardinal) on Mar 18, 2012 at 00:18 UTC | |
by aaron_baugher (Curate) on Mar 18, 2012 at 01:03 UTC | |
|