Perl monking (was Menu{Master,Maestro,etc} question(s)
Jay R. Ashworth
jra at baylink.com
Mon May 14 11:56:09 PDT 2007
On Thu, May 10, 2007 at 12:24:07PM -0400, Jay R. Ashworth wrote:
> > perl -pi.bak -e 'BEGIN {$line=shift; $sub=shift;} s/^(.+:[^:]+")[^"]+(".*)/$1${sub}$2/' $2 $3 $1
> >
> > This is untested, but based on the -p documentation. Specifically:
> >
> > "BEGIN and END blocks may be used to capture control
> > before or after the implicit loop, just as in awk."
>
> Aha! Yeah; figures they'd steal that too. I'll try that version.
I actually ended up with:
perl -pi.bak -e 'BEGIN {$label=shift; $sub=shift;}
if (/^$label:/)
s/^(.+:[^:]+")[^"]+(".*)/$1${sub}$2/;' $2 $3 $1
You forgot the if clause. The trailing semicolon, too, in the -e, but
I suspect that's optional.
Testing now.
Cheers,
-- jra
--
Jay R. Ashworth jra at baylink.com
Designer Baylink RFC 2100
Ashworth & Associates The Things I Think '87 e24
St Petersburg FL USA http://baylink.pitas.com +1 727 647 1274
More information about the Filepro-list
mailing list