Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
If there is a character 'D' below the {TT} I have to delete all the characters from the line which has text {TT} and to begining of another {TT}. Now I have code to store only text between {TT} and {TAG}.#!/usr/bin/perl while(<DATA>){ if (/\{TT\}/ .. /^\{TAG\}/) { unless (/^\{(TT|TAG)\}/) { $deletestrings = $_; #if($_ =~ m/^D$/){ print $_; # $_ = '' 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: delete lines till
by ikegami (Patriarch) on Aug 25, 2009 at 06:04 UTC | |
by Anonymous Monk on Aug 25, 2009 at 06:38 UTC | |
by Anonymous Monk on Aug 25, 2009 at 10:54 UTC | |
|
Re: delete lines till
by Sewi (Friar) on Aug 25, 2009 at 07:32 UTC | |
by Anonymous Monk on Aug 25, 2009 at 10:46 UTC | |
by Anonymous Monk on Aug 26, 2009 at 03:59 UTC | |
|
Re: delete lines till
by Anonymous Monk on Aug 25, 2009 at 06:02 UTC | |
|
Re: delete lines till
by bichonfrise74 (Vicar) on Aug 25, 2009 at 19:13 UTC | |
by Anonymous Monk on Aug 26, 2009 at 11:55 UTC |