in reply to Re: Re: File regex question
in thread File regex question
Something like this (untested) code may be what your looking for.
#! 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.
|
|---|