#!perl use strict; use warnings; my $readfile = 'blah.csv'; my $writefile = 'bleh.csv'; my $row = <$fh>; my $found = 0; my @cols; my (@col1,@col2); my @words = split(//,@col1); open my $fh, "<", $readfile; open my $wfh, "<", $writefile; foreach (<$fh>) { tr /a-z/A-Z/; chomp; my @cols = split /\;/; push @col1, $cols[0]; push @col2, $cols[1]; if ( @col2 =~ m/$words[$_](\d+)/ ) { $found++; @words++; } open($wfh) or die "YARRG: $!"; print $wfh "$row';'@words';'$found"; $found = 0; @words = 0; }