in reply to Re^5: String comparison in an array
in thread String comparison in an array
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 (<FILE1>) { 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 $fillarr +1[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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: String comparison in an array
by Eily (Monsignor) on Aug 08, 2018 at 14:33 UTC | |
by newperlbie (Acolyte) on Aug 08, 2018 at 14:52 UTC | |
by Eily (Monsignor) on Aug 08, 2018 at 14:57 UTC | |
by newperlbie (Acolyte) on Aug 08, 2018 at 15:03 UTC | |
|
Re^7: String comparison in an array
by Marshall (Canon) on Aug 09, 2018 at 21:41 UTC |