use 5.010; use strict; use warnings; sub sayit { say $1 // 'undef'; } do { '42' =~ /(\d+)/ and sayit(); }; sayit(); __END__ 42 undef