c:\@Work\Perl\monks>perl -wMstrict -le "'zot' =~ m{ (zot) }xms; ;; for my $s ( 'http://172.20.37.115:8080/se/1.0/pro/subs/198968/', 'http://172.20.37.115.8080/se/1.0/pro/123456', ) { my ($var) = $s =~ m{ (\d+) \z }xms; print '$var is ', defined($var) ? '' : 'UN', 'defined'; print qq{'$s' -> '$var' (\$1 is '$1')}; } " $var is UNdefined Use of uninitialized value $var in concatenation (.) or string at -e line 1. 'http://172.20.37.115:8080/se/1.0/pro/subs/198968/' -> '' ($1 is 'zot') $var is defined 'http://172.20.37.115.8080/se/1.0/pro/123456' -> '123456' ($1 is '123456')