You have a text file with records which start with a newline, a line of text, and another newline. You want to print selected lines from a record, if both the following are true: the record title matches a predefined list, and the phone number is in the record. The title of the record determines which lines of the record to print.
Your question for us is how to find out what record you're looking at.
It sounds like bikenomad's code should do almost exactly that, if you simply include print statements inside the if statement:
Does this help?if ($lastHeading eq 'MEANINGLESS TEXT') { print $lines[2]; # third line print $lines[5]; # sixth line print $lines[7]; # eighth line } elsif ($lastHeading eq 'ALTERNATIVE TEXT') { print $lines[3]; # fourth line print $lines[5]; # sixth line print $lines[7]; # eighth line
In reply to Re: Re: Re: Can PERL know a line without matching?
by da
in thread Can PERL know a line without matching?
by brassmon_k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |