- or download this
$2=ab # Only thing matched
$2=a # Only thing matched
$2=a # First thing matched
- or download this
$2=ab # Only thing matched
$2=a # Only thing matched
$2=b # Last thing matched
- or download this
$ perl -e'"ab" =~ /((\w+)(?{print defined $^N ? "\$^N=$^N\n" : "\$^N n
+ot defined\n"})){2}/;'
$^N=ab
$^N not defined
$^N=b