[Israel.pm] perl -i -pe question

sawyer x xsawyerx at gmail.com
Mon Feb 20 01:17:24 PST 2012

On Mon, Feb 20, 2012 at 9:33 AM, Dov Levenglick <dov.levenglick at gmail.com>wrote:

> Why isn't $a incrementing in this one-liner:
> perl -ibak -pe "$a=1; $a++ if (s/   ADDR_RESET_PAIR/    $a
> ADDR_RESET_PAIR/);" file.txt

-p is line based. Perhaps $a is getting initialized every time.
If it doesn't maintain the scope, there is no way it will work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20120220/b54a62a3/attachment.htm 

More information about the Perl mailing list