I should start by saying I'm still very new to Perl, and that this is only homework in the sense that I am trying to remedy my ignorance. I want to know whether or not something is possible, and where I should go to read and learn more.
Here's my situation: I have an input file with some junk at the top of it, and then some lines I want to do something with. I know the last line of junk contains a certain pattern. What I wanted to do was tell Perl to start doing stuff after it read the line with that pattern in it. But I'm not sure how to do that within the while loop, or even if that's possible.
What I ended up doing, because I knew how, was to identify and skip the junk lines (all of which begin with either "qcp" or "#", or are blank) and then process all the other lines the way I wanted to, thus:
#!/usr/bin/perl use warnings; use strict; my ($vars); while <DATA>{ if (/^qcp|^\#|^\s?\n/){} else {do stuff here} } __DATA__ #data... qcp_junk qcp_more junk #cardtype... NOT_JUNK NOT_JUNK etc....
If I know that #cardtype Always begins the last line of junk, what could I do instead?
Thanks for any insight or wisdom you care to offer.
Pax,
NovMonk
In reply to Processing lines after a pattern in a while loop by NovMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |