%hash = ( 'foo' => 'bar', 'Foo' => 'Bar', 'FOO' => 'BAR', 'foO' => 'baR', 'Is' => 'Was', ); $string =~ s/(foO)/$hash{$1}/;