in reply to How do I use stat

Try <code> and </code> tags =)

Close. stat's time functions give you the times since the epoch so you need to figure out how many seconds it's been. You should be able to get away with this:

if ( time - (stat $_)[9] > 1200 ) { print "ERROR MESSAGE" }
This gets rid of the variables I'm guessing you're not using, as well.

Let me know if that works for ya. =)

-Ducky

Replies are listed 'Best First'.
Re: Re: How do I use stat
by bgator29 (Initiate) on Sep 27, 2001 at 22:43 UTC
    thanks for the tips. I'm new to PERL ( you could probably tell). That really got me off to a great start.........one more question though please. Aside from the code that you gave me, do I have to have anything else because i think that the (stat $_) is not actually working. Do I need to have any code before i make the if comparison?? Hopefully that makes sense Thanks a lot

      No problem! That is exactly why we're here =)

      One thing to consider when doing stat is that it operates off of the current working directory. Perhaps $_ isn't really pointing to a valid file? Proper error checking is very good practice and often needs very little extra modification:

      die "Bigger problem: '$_' doesn't exist!" if not -e $_ ; if ( time - (stat $_)[9] > 1200 ) { print "ERROR MESSAGE" }
      Oh, and no, stat works just fine by its lonesome. No prep is needed.

      -Ducky