{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
In reply to print line by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |