I have problems matching perl regex with a network script I have, I managed to set the behavior in a small fragment.
Take this Perl snippet for Perl 5.10.0 on Debian:
use warnings;
use strict;
my $line = "Version: 0\r\n";
my($version) = $line =~ m/^Version:(\s\d+)\r\n$/;
print "1st failed \n" if not $version;
($version) = $line =~ m/^Version:\s(\d+)\r\n$/;
print "2nd failed \n" if not $version;
($version) = $line =~ m/^Version:\ (\d+)\r\n$/;
print "3th failed \n" if not $version;
With this output:
2nd failed
3th failed
Apparently, the only difference between the 1st and 2nd is the movement of space from the extracted template, which theoretically should not modify the regular expression at all, but only the returned part.
I do not understand why the 2nd and 3rd do not work exactly the same as the first.
EDIT:
$version, , script, , op, , ( ) .