#!/usr/bin/perl -w use strict; my %dirs = (   './space/dir/dirname1' => 'Wert1',   './space/dir/dirname2' => 'Wert2',   './space/dir/dirname3' => 'Wert3',   './space/dir/dirname4' => 'Wert4', ); my %other_dirs = (   dirname1 => 'dirname4',   dirname2 => 'dirname5',   dirname3 => 'dirname99',   dirname4 => 'dirname100' ); foreach (keys %dirs) {   # matched bis zum letzten Slash, ein Slash muss enthalten sein   next unless /^(.+)\/(.+)$/ && exists $other_dirs{$2};   function1($_,$dirs{$_},"$1/$other_dirs{$2}",$other_dirs{$2}); }