#!/usr/bin/perl -w $fn=$ARGV[0]; open(FH, $fn) || die "Cannot open file"; while( <FH> ) { chomp($_); $href{$1} = $2 if $_ =~ /(\S+)\s+(\S+)/; } while (my ($key, $value) = each(%href)) { #print $key. ", ". $value."\n"; } close FH; $fh=$ARGV[1]; open(FD, $fh) || die "Cannot open file"; my @input_array = <FD>; foreach my $line (@input_array) { chomp($line); my $cnt = 0; map {($line =~ /$_/)?++$cnt:$cnt}keys %href; print "$cnt $line\n"; } close FD;
In reply to Map function slowing down program by ashnator
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |