use strict;
use warnings;
####
print "\n Enter the file name :>";
chomp( my $filename1 = );
####
my @lines = ();
####
open my $fh, '<', $filename1 or die "Cannot find the file $filename1: $!";
####
while (<$fh>)
{
push @lines, $_;
}
####
close $fh;
####
open my $w, '>', 'Result.txt' or die "Cannot open the file Result.txt: $!";
####
foreach my $line (@lines)
{
my @chr_fields = grep {$_ =~ m/^chr/} split ("\t", $line)
if ( # If...
@chr_fields == 2 # ...there are exactly two chr* fields...
&& $chr_fields[0] ne $chr_fields[1] # ...which are not exactly the same...
) {
print $w $line;
}
}
close $w;