$ perl -wE 'use Data::Dump; my %h; dd \%h; $_ = "a_b_c"; $h{/a_(.*)_c/} = boom_$1; dd \%h'
{}
Can't call method "boom_" on an undefined value at -e line 1.
####
$ perl -wE 'use Data::Dump; my %h; dd \%h; $_ = "a_b_c"; $h{/a_(.*)_c/} = "boom_$1"; dd \%h'
{}
Use of uninitialized value $1 in concatenation (.) or string at -e line 1.
{ 1 => "boom_" }
####
$ perl -wE 'use Data::Dump; my %h; dd \%h; $_ = "a_b_c"; $h{(/a_(.*)_c/)[0]} = "boom_$1"; dd \%h'
{}
Use of uninitialized value $1 in concatenation (.) or string at -e line 1.
{ b => "boom_" }
####
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dump;
my %hash = (
xxx_text10_yyy => 1,
xxx_text11_yyy => 1,
mmm_text12_nnn => 1,
mmm_text13_nnn => 1,
abc_text6_ghi => 1,
abc_text7_ghi => 1,
abc_text8_ghi => 1,
abc_text9_ghi => 1
);
my %xref = (
abc => 'boom',
mmm => 'doom',
xxx => 'zoom',
);
my $re = qr{(?x: ^ ( [^_]+ ) _ ( [^_]+ ) )};
/$re/ and $hash{$_} = join '_', $xref{$1}, $2 for keys %hash;
dd \%hash;
####
{
abc_text6_ghi => "boom_text6",
abc_text7_ghi => "boom_text7",
abc_text8_ghi => "boom_text8",
abc_text9_ghi => "boom_text9",
mmm_text12_nnn => "doom_text12",
mmm_text13_nnn => "doom_text13",
xxx_text10_yyy => "zoom_text10",
xxx_text11_yyy => "zoom_text11",
}