From tpm.ats at spamgourmet.com Thu Apr 2 08:00:50 2015 From: tpm.ats at spamgourmet.com (Antonio Sun) Date: Thu, 2 Apr 2015 11:00:50 -0400 Subject: [tpm] Skip lines when "perl -wn" Message-ID: The "-n" causes Perl to assume a loop around the program, which makes it iterate over filename arguments somewhat like `sed -n` or awk. Now, is it possible to skip some lines myself in such "perl -wn" script? #!/usr/bin/perl -wn if (/my case/) { # Skip two lines <>; <>; # Deal with the rest } The above is not working for me. $_ is stuck at the same line/content. How to skip some lines in such "perl -wn" script? Thanks Antonio -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at starnix.com Thu Apr 2 08:33:18 2015 From: matt at starnix.com (G. Matthew Rice) Date: Thu, 2 Apr 2015 11:33:18 -0400 Subject: [tpm] Skip lines when "perl -wn" In-Reply-To: References: Message-ID: On Thu, Apr 2, 2015 at 11:00 AM, Antonio Sun wrote: > Now, is it possible to skip some lines myself in such "perl -wn" script? Do you mean like this: #!/usr/bin/perl -wn BEGIN { our $skipping = 0; } if (/c/ || $skipping) { $skipping = 1 - $skipping; next; } print; __END__ The script and sample data is attached. -- G. Matthew Rice gpg id: EF9AAD20 -------------- next part -------------- A non-text attachment was scrubbed... Name: a.pl Type: text/x-perl-script Size: 132 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: a.dat Type: application/octet-stream Size: 15 bytes Desc: not available URL: From tpm.ats at spamgourmet.com Thu Apr 2 08:51:56 2015 From: tpm.ats at spamgourmet.com (Antonio Sun) Date: Thu, 2 Apr 2015 11:51:56 -0400 Subject: [tpm] Skip lines when "perl -wn" In-Reply-To: References: Message-ID: Please disregard the following email as I've found the problem -- I was doing "<>" but checking on "$_", which isn't affected by "<>". On Thu, Apr 2, 2015 at 11:00 AM, Antonio Sun wrote: > The "-n" causes Perl to assume a loop around the program, which makes it > iterate over filename arguments somewhat like `sed -n` or awk. > > Now, is it possible to skip some lines myself in such "perl -wn" script? > > #!/usr/bin/perl -wn > > if (/my case/) { > # Skip two lines > <>; <>; > # Deal with the rest > } > > > The above is not working for me. $_ is stuck at the same line/content. > > How to skip some lines in such "perl -wn" script? > > Thanks > > Antonio > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From legrady at gmail.com Thu Apr 2 15:25:51 2015 From: legrady at gmail.com (Tom Legrady) Date: Thu, 02 Apr 2015 18:25:51 -0400 Subject: [tpm] Skip lines when "perl -wn" In-Reply-To: References: Message-ID: <551DC1EF.4090108@gmail.com> I have good results using $., the line number of the file being read. perl -ne' next if $. <= 2; printf "%3d - %s". $., $_; ' Build.PL perl -MEnglish -ne 'next if $NR <= 2; printf "%3d - %s". $., $_; ' Build.PL perl -MEnglish -ne 'next if $INPUT_LINE_NUMBER <= 2; printf "%3d - %s". $., $_; ' Build.PL skips lines 1 & 2, and outputs the remainder. Tom On 04/02/2015 11:00 AM, Antonio Sun wrote: > The "-n" causes Perl to assume a loop around the program, which makes > it iterate over filename arguments somewhat like `sed -n` or awk. > > Now, is it possible to skip some lines myself in such "perl -wn" script? > > #!/usr/bin/perl -wn > > if (/my case/) { > # Skip two lines > <>; <>; > # Deal with the rest > } > > > The above is not working for me. $_ is stuck at the same line/content. > > How to skip some lines in such "perl -wn" script? > > Thanks > > Antonio > > > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.s.doyle at gmail.com Fri Apr 17 08:53:07 2015 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Fri, 17 Apr 2015 11:53:07 -0400 Subject: [tpm] April 29th meeting scheduled Message-ID: Hello TPM, Our next meeting is all booked. We've got to speakers on the go. Doug Hoyte will be giving his talk "Truncating Unicode" and Richard Farr will be talking about Efficient Sparse Arrays. Details are here: http://www.meetup.com/Toronto-Perl-Mongers/events/221913446/ Thanks, D -- dave.s.doyle at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From olaf.alders at gmail.com Wed Apr 29 15:39:15 2015 From: olaf.alders at gmail.com (Olaf Alders) Date: Wed, 29 Apr 2015 18:39:15 -0400 Subject: [tpm] tonight's hangout Message-ID: https://plus.google.com/hangouts/_/hoaevent/AP36tYebsQfLTCU2Y49sxPlCCwtZpNaC3quiiwxCZxHMGkv8ab4VwQ