"This might be a dumb question, but does your same_mod_time return 0 or 1 without the return?"
It returns TRUE or FALSE, i.e. whatever (stat($_[0]))[9] == (stat($_[1]))[9] evaluates to.
In string context, that would be "1" or "";
in numeric context, that would be 1 or 0.
Modifying the test code I posted previously to demonstrate this:
$ > xxx 2> yyy
$ perl -Mstrict -Mwarnings -E '
sub same_mod_time { (stat($_[0]))[9] == (stat($_[1]))[9] }
say ">>>" . same_mod_time(qw{xxx yyy}) . "<<<";
'
>>>1<<<
$ perl -Mstrict -Mwarnings -E '
sub same_mod_time { (stat($_[0]))[9] == (stat($_[1]))[9] }
say 0 + same_mod_time(qw{xxx yyy});
'
1
$ > xxx
$ perl -Mstrict -Mwarnings -E '
sub same_mod_time { (stat($_[0]))[9] == (stat($_[1]))[9] }
say ">>>" . same_mod_time(qw{xxx yyy}) . "<<<";
'
>>><<<
$ perl -Mstrict -Mwarnings -E '
sub same_mod_time { (stat($_[0]))[9] == (stat($_[1]))[9] }
say 0 + same_mod_time(qw{xxx yyy});
'
0
The presence or absence of the return keyword, in that subroutine, is immaterial. Here's what the doco says:
"return EXPR
...
Returns from a subroutine, eval, or do FILE with the value given in EXPR.
...
In the absence of an explicit return, a subroutine, eval, or do FILE automatically returns the value of the last expression evaluated. ..."
| [reply] [Watch: Dir/Any] [d/l] [select] |