open FILE,$file; my $in_entry='no'; while(my $line = ){ if($line =~ //){ $in_entry='yes'; open OUTPUT, '>/tmp/bind_single.xml'; print OUTPUT $line; } elsif($line =~ /<\/BIND-Interaction>/){ print OUTPUT $line; $in_entry='no'; close OUTPUT; my $doc = new XML::EasyOBJ('/tmp/bind_single.xml'); ##do the parsing here ##stop the parsing here unlink('/tmp/bind_single.xml'); } elsif($in_entry eq 'yes'){ print OUTPUT $line; } }