I'm observing a difference in behavior between WeBWorK and Perl with regard to the match capture groups. The below example attempts to search the value 234 for the value 5. A match is apparently registered in WeBWorK but Perl returns the anticipated result of an unsuccessful match. I would appreciate any insight on these differing responses.
PG code (Returns a value of 1)
--------------------------------------------------------
DOCUMENT();
loadMacros("PGstandard.pl");
$num="234";
BEGIN_TEXT
WeBWorK match value: \{match($num)\}$BR
END_TEXT
sub match{
my($foo) = @_;
$foo =~ /(5)/;
if(!defined($1)){return 0; }
else{ return 1; }
}
ENDDOCUMENT();
Perl code (Returns a value of 0)
--------------------------------------------------------
$num="234";
$ret_val = match($num);
print "Perl match value: $ret_val\n";
sub match{
my($foo) = @_;
$foo =~ /(5)/;
if(!defined($1)){ return 0; }
else{ return 1; }
}