#!/usr/bin/perl use strict; use warnings; use IO::File; open (FILE, 'numbers.txt'); my @fileone = ; close (FILE); open (FILE, 'numbers.txt'); my @filetwo = ; close (FILE); my $count1="0"; my $line; my $pattern; foreach $pattern (@fileone) { chomp $pattern; foreach $line (@filetwo) { chomp $line; if ($line =~ /$pattern/) { $count1++; #my @elements = split ('~',$line); #my $cmts = $elements[1]; } } print "$pattern appeared $count1\n"; $count1="0"; } $ ./test_v2.pl one appeared 3 two appeared 2 three appeared 1 one appeared 3 five appeared 1 two appeared 2 ten appeared 1 one appeared 3