Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
{IT} is the start of one file. How to print the {IT} line if both {LINE} and {ID} doesn't exists.#!/usr/bin/perl my $flag; while(<DATA>){ if (/^({\w+})/) { $flag = $1; } elsif ($flag =~ m/{TAG}/){ print $_; } elsif ($flag =~ m/{ID}/){ print $_; } } __DATA__ {IT} 343 1 {DATE} 090104 {LINE} LEGISLATORS VISIT SENIOR APARTMENT COMPLEX {TAG} 1lutherridge0104.ART {ID} 234 {IT} 434 2 {DATE} 090104 {LINE} LEGISLATORS VISIT SENIOR APARTMENT COMPLEX
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print line
by GrandFather (Saint) on Nov 25, 2009 at 06:53 UTC | |
|
Re: print line
by chromatic (Archbishop) on Nov 25, 2009 at 06:52 UTC | |
|
Re: print line
by Khen1950fx (Canon) on Nov 25, 2009 at 06:53 UTC | |
|
Re: print line
by bichonfrise74 (Vicar) on Nov 25, 2009 at 22:02 UTC |