#!/usr/local/bin/perl use strict; use warnings; my $file_an=shift(@ARGV); my @files_in=@ARGV; my %hash = read_an($file_an); wort_zu_zahl($_,%hash) for(@files_in); sub read_an{ my $file=shift; my %hash=(); open(my $anfh, '<', $file) or die ("ERROR open $file ($!)\n"); while (my $line = <$anfh>){ chomp $line; my ($k, $v) = split /\s+/, $line; $hash{$k} = $v; } close($anfh); return %hash; } sub wort_zu_zahl{ my $file=shift; print "FILE: $file\n"; my %hash=@_; open(my $infh, '<', $file ) or die("ERROR open $file ($!)\n"); while(my $line= <$infh> ){ my %local = (); chomp $line; my @words = split /\s+/, $line; $local{$_} += $hash{$_} for @words; print join(",", map{$local{$_} || 0}keys(%hash) )."\n"; } close($infh); }