I am using a subtitle as an argument for another sub. Code example:
test(isInString(), 'second parameter', 'third parameter'); sub test { my ($boolean, $second, $third) = @_; print "boolean: $boolean\n second: $second\n third: $third\n"; } sub isInString { my $searchFor = 'a'; my $searchIn = 'bcd'; return ($searchFor && $searchIn && ($searchIn =~ $searchFor)); }
In the above example, I would expect the return statement in "isInString" to evaluate to false ('' or undef or something else that might be in perl) and this would be passed to “Test” as parameter # 1 , su, essentially
Test(undef, 'second parameter', 'third parameter');
This is not what is happening. isInString returns an empty array, and essentially you get
Test('second parameter', 'third parameter');
Returning from isInString in the perl debugger gives:
return context list from main :: isInString: empty array
I assume this is a perl context, I can assign a scalar variable first, and it works fine:
my $bool = isInString(); Test($bool, 'second parameter', 'third parameter');
the debugger gives - the scalar context returns from main :: isInString: ''
EDIT I deleted all parsers with the same result:
sub isInString { my $searchFor = 'a'; my $searchIn = 'bcd'; return $searchFor && $searchIn && $searchIn =~ $searchFor; }
The debugger still gives:
return context list from main :: isInString: empty array
Can someone explain why the list / empty array is returned in this scenario?