Perl print unless regex and line counts -
i have working sorting through zone file automated deletions..
perl -i -ne 'print unless (/#$domainname/ , \$n=7) .. not \$n--' named.conf.ext
(escaping n required work, guess else thinks main script has n variable passed?)
this call within perl script , clean not having call shell re-run perl perl script it, , having main script it.
not perl expert here can tell :) have tried things like
open (datain, "<named.conf.ext"); open (dataout, "> named.conf.tmp"); while (<datain>){ print unless (/#foo.com/ , $n=7) .. not $n-- dataout; } close dataout; close datain;
and few variants, complains syntax error @ test line 4, near "-- dataout"
i'm sure i'm being spacey @ this, , answer right in front of me, 2 days, think brain needs kick start in where.
thanks
it's normally
print dataout;
which short
print dataout $_;
so want
print dataout unless (/#foo.com/ , $n=7) .. not $n--;
or longer
print dataout $_ unless (/#foo.com/ , $n=7) .. not $n--;
Comments
Post a Comment