use strict; use warnings; use Data::Dump; use Text::CSV; use List::MoreUtils qw{ any }; my $first = 'computer'; my $last = 'printer'; my $in = 0; my @keys; open FILE1, "types.txt" or die $!; while () { if (defined(my $key = (split)[-5])) { if ($key eq $first .. $key eq $last) { $in = 1; push @keys, $key; } elsif ($in && $key eq $last) { push @keys, $key; } else { $in = 0; } } } dd @keys; my $filename = "orders.csv"; my $csv = Text::CSV->new ( { binary => 1 } ); open my $fh, "<:encoding(Latin-1)", "orders.csv" or die "Cannot open $ +filename"; my $do_skip_test = 1; while(my $line = <$fh>) { if ($do_skip_test) { my (@fillarr1) = split ';',$line; if ((grep {$fillarr1[14] eq $_ +}@keys)) #this is bothering me, as hardcoded comparison like $fillarr1[14] =~ /computer/ is successful { #$do_skip_test = 0; my (@fillarr) = split ';',$line; print "\n", join "\t", @fillarr[0, 1, 3, 4, 5, 14]; } } } close($fh);