Is there any way to force a hash slice to interpolate without spaces when used in a regex? I have a huge hash table like so:
my %k;
$k{'A'} = 'Foo';
$k{'B'} = 'Bar';
$k{'C'} = 'Baz';
I want to replace all occurences of 'FooBarBaz' with something else, say "stuff". However, this doesn't work:
s/@k{qw(A B C)}/stuff/;
because it interpolates to
s/Foo Bar Baz/stuff/;
rather than
s/FooBarBaz/stuff;
This is particularly irritating because
print @k{qw(A B C)}, $/;
yields "FooBarBaz". Any thoughts? Yes, I could do
$x = join('', @k{qw(A B C)});
s/$x/stuff/;
But that's so ugly...