$ 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_" }