#!/usr/bin/perl -w use strict; use warnings; my $readfile = "C:/Documents and Settings/mydir/Desktop/TARGETING.gb"; my $writefile = "C:/Documents and Settings/mydir/Desktop/TARGET.gb"; open my $in, "<", $readfile or die "couldn't open $readfile: $!"; open my $out, ">", $writefile or die "couldn't open $writefile: $!"; my $state; while(my $line =<$in>){ if ($line=~/^([A-Z]+)/) { $state=$1; } print $out $line unless $state eq "COMMENT"; } close $in; close $out