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