Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular exp help needed !! 2

Status
Not open for further replies.

rao12

IS-IT--Management
Jan 10, 2001
9
0
0
US
Hi,

I have a file with many input lines and i want to exclude
the lines which look like from my output file "output_file"..

-----------------|------------------[ added ]----------


my code which i thought could solve looks like this

open(INP, "input_file");
open(ONP , ">> output_file");

while(<NP>){
$lin = $_;
$lin =~ s/^-+\|-+\[ added \]-+//g;
print ONP &quot; $lin&quot;;
}
close INP;
close ONP;


Thanks
Rao
 

while ($lin = <NP>)
{
if ($lin =~ /-----------------\|------------------[ added ]----------/) { next; }
else { print ONP &quot;$lin&quot;;
}

That could be a little more concise, but, it should work.

HTH


keep the rudder amid ship and beware the odd typo
 
more concise :) like this?
[tt]
while (<NP>)
{
[tab]next if /-----------------\|------------------[ added ]----------/);
[tab]print ONP &quot;$_&quot;;
}
[/tt]
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
or like this....

while (<NP>) {
next if (/-+\|-+[ added ]-+/);
print ONP;
}


TMTOWTDI - ;-)


keep the rudder amid ship and beware the odd typo
 
<grin> I should know better than to cross regexes with *you* goBoating! Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top