use strict; use warnings; use Getopt::Long; GetOptions( 'i=s' => \$infile, ); open INFILE, '<', "$infile", or die "cant open file $infile"; open OUTFILE, '>', "$results.txt" or die "cant open"; while () { my $line = $_; chomp($line); if ( $line =~ m/^#/g ) { next; } elsif ( $line =~ m/^$/g ) { next; } elsif ($line) { my @taxonomic = $_; foreach (@taxonomic) { ( $taxon, $val1, $val2, $val3 ) = split( /\t/, $_ ); } # here is the problem my (@orden) = ( $taxon =~ m/(\w*ales)[\;]?/g ); foreach (@orden) { if ( $_ =~ m/^$/g ) { next; } elsif ( $_ =~ m/^unclassified/g ) { next; } else { print OUTFILE "$_\n"; } } close INFILE; close OUTFILE; exit;