in reply to Re: delete lines till
in thread delete lines till
Now the above writes the lines which is between {TT} and {TAG}. The output is#!/usr/bin/perl while(<DATA>){ if (/\{TT\}/ .. /^\{TAG\}/) { unless (/^\{(TT|TAG)\}/) { $deletestrings = $_; #if($_ =~ m/^D$/){ print $_; open FILE, '>list.txt'; print FILE $_; close FILE; $_ = '' if index( $_, "$deletestrings" ) >= 0; } } } __DATA__ S 9912290449 00005941^B{TT} D {TAG} 9912290449 {PUBLICATION} THE OS {DATE} 000101 S 9912290450 00005941^B{TT} R {TAG} 9912290450 {DATE} 000101 {TDATE} Saturday, January 1, 2000 S 9912290451 00005941^B{TT} D {TAG} 9912290451 {DATE} 000101 {TDATE} Saturday, January 1, 2000
How to write only two lines which has the character D to the file. In the file: onlyS 9912290449 00005941^B{TT} D S 9912290450 00005941^B{TT} R S 9912290451 00005941^B{TT} D
should be writeenS 9912290449 00005941^B{TT} D S 9912290451 00005941^B{TT} D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: delete lines till
by Anonymous Monk on Aug 26, 2009 at 03:59 UTC |