Perl monking (was Menu{Master,Maestro,etc} question(s)
Jay R. Ashworth
jra at baylink.com
Thu May 10 09:24:07 PDT 2007
On Thu, May 10, 2007 at 10:36:28AM -0400, Fairlight wrote:
> Jay Ashworth blabbed on about:
> > I read it as "if you use -i, then your -e commands will be used as the
> > target of
> >
> > while (<>) {};"
> >
> > IE: it automagically does all the context for you, like awk, and all
> > you have to do it write the body of the loop. I'm gonna test it in
> > about 10 minutes, so I'll know. The only thing that might be a problem
> > is that in -i mode, there may be no way to get the shifts *out* of the
> > loop, which would, I think, be fatal.
>
> Upon scrolling down the perlrun manpage, I see you're correct based on
> the examples given--also upon reading the docs on -p in the same page.
>
> My mistake for skimming yesterday. In that event:
>
> 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.
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