Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Intermittent bug in module: File not getting deleted as expected

by nysus (Vicar)
on Feb 19, 2019 at 18:47 UTC ( #1230184=note: print w/replies, xml ) Need Help??


in reply to Intermittent bug in module: File not getting deleted as expected

OK, I'm beginning to think this is some kind of bug with -M, or the OS (happening on Linux and Mac, though). If I add a delay into the test script of a whole 5 seconds, the file age will sometimes be reported as a negative value -1.15740740740741e-05.

I think I'm going to solve this by simply changing it from -M $file > 0 to -M $file > -1 as suggested above.

Thanks!

But curious to know why it's reporting a negative value at all.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

  • Comment on Re: Intermittent bug in module: File not getting deleted as expected
  • Download Code

Replies are listed 'Best First'.
Re^2: Intermittent bug in module: File not getting deleted as expected
by tybalt89 (Parson) on Feb 19, 2019 at 18:58 UTC

    If I understand your problem (which is very iffy).

    -M measures from start of program (kept in $^T). sleep() just make things worse. Adjust start of program. $^T = time; at or after creation of file will fix;

      - M reports the age of the file in days.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

        From perldoc -f -M

        -M  Script start time minus file modification time, in days.

Re^2: Intermittent bug in module: File not getting deleted as expected
by stevieb (Abbot) on Feb 19, 2019 at 18:51 UTC

    I think you mean:

    if (-M $file > -2)

    In other words, -1.15 is less than -1, not greater than ;)

    Either way, it would be nice to find out exactly what's happening here. I'll play around later. If you happen to find anything, post back please.

      I think we have the answer for this behavior. See the comment further down and this. It seems that the time the script starts is factored into the age of the file. Still trying to wrap my head around it, though. Seems weird.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

      Well, it's to the power of 10^-5, so -.000015.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

        Ahhh, of course. I overlooked that part of your number :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1230184]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2019-06-25 23:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (108 votes). Check out past polls.

    Notices?