$ perl -wE 'my $s = "foo bar"; $s =~ /(bar)/; say ${^PREMATCH}' foo $ perl -wE 'my $s = "foo bar"; $s =~ /bar/; say ${^PREMATCH}' Use of uninitialized value $^PREMATCH in say at -e line 1. $