#! perl -w
use strict;
open IN, '<', 'file' or die $!;
open OUT, '>', 'temp' or die $!;
while( <IN> ) {
s[ (?<=\\|/) (.*?) (?=\\|/) ][
(my$x=$1) =~ s{ }{_}g;
$x
]gex;
print OUT;
}
close IN;
close OUT;
rename 'file', 'file.bak';
rename 'temp', 'file';
You could also look at using $INPLACE_EDIT ($^I) to have perl do the backup and rename for you.
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.
|