in reply to Re: Will checking last modified date take more time than just overwriting?
in thread Will checking last modified date take more time than just overwriting?

This might be a dumb question, but does your same_mod_time return 0 or 1 without the return?

Data details:

Thanks for stopping by.

Have a cookie and a very nice day!
Lady Aleena

Replies are listed 'Best First'.
Re^3: Will checking last modified date take more time than just overwriting?
by kcott (Archbishop) on Aug 19, 2013 at 09:14 UTC
    "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. ..."

    -- Ken