use strict; use warnings; my $HR_wnt = {'res.ldlibrarypath' => 'Flobble=/opt/app/Flobble:'}; my $HR_unx; my $HR_component; my $target = 'Flobble'; for my $hashref ($HR_wnt, $HR_unx, $HR_component) { for my $id (keys %$hashref) { if ($id eq 'res.ldlibrarypath') { if ($$hashref{$id} =~ /=\//) { $$hashref{$id} =~ s/\/opt\/app\/$target.*?://; } } } } print $HR_wnt->{'res.ldlibrarypath'}; #### Flobble=