in reply to Re^2: search text file
in thread search text file
thank you for your help.i solve it as follow
#!/usr/bin/perl use warnings; use strict; open DOMAINLIST, '<', 'domainlist' or die "Cannot open 'domainlist' be +cause: $!"; chomp( my @list = <DOMAINLIST> ); close DOMAINLIST; open RESULT, '<', 'result' or die "Cannot open 'result' because: $!"; my $domain; #define a hash for count each domain. my %count; while ( my $line = <RESULT> ) { foreach $domain ( @list ) { if ($line =~ /(\Q$domain\E)/g){ $count{$1}++; } } } close RESULT; foreach $domain(keys %count){ print"$domain=$count{$domain}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: search text file
by jwkrahn (Abbot) on Jul 26, 2011 at 23:07 UTC |