#!/usr/bin/perl -w use strict; use Data::Dumper; my %hash = ( 'f_foo' => 'bleh', 'f_bar' => 'blarf', 'f_bas' => 'heh', ); foreach(keys %hash) { $hash{$1} = $hash{$_} if(m/f_(.*)/); } print Dumper(\%hash);