in reply to Re: Removing blank lines from array
in thread Removing blank lines from array

As small improvement, you can use $. instead of $cnt, as is documented in perlvar.

Replies are listed 'Best First'.
Re: Re: Re: Removing blank lines from array
by Chmrr (Vicar) on Feb 28, 2002 at 19:00 UTC

    Actually, his specific point was that one probably didn't want to count the number of lines read from the file, but instead the number of lines printed. Because of the presence of the next statement, they're not the same thing. Thus the use of the $cnt variable to keep track of the number of lines printed.

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'