#!/usr/bin/perl use strict; use warnings; my $file1 = '/pfad/datei1.txt'; my $file2 = '/pfad/dat2.txt'; my $file3 = '/pfad/dat3.txt'; my %hash; for my $file( $file1, $file2 ){ open my $in, '<', $file or die $!; while( my $line = <$in> ){ chomp $line; my ($count,$url) = split /\s*:\s*/, $line; $hash{$url} += $count; } close $in; } open my $out, '>', $file3 or die $!; for my $key ( keys %hash ){ print $out $hash{$key},": ", $key, "\n" or die $!; } close $out or die $!;