in reply to Re: I don't want to die
in thread I don't want to die

Thanks.. eval works perfectly. I used ctime as I want the time that the file was added to the directory by another script. So far ctime seems to return the correct files and my script continues to run after the eval
Thanks again!

Replies are listed 'Best First'.
Re^2: I don't want to die
by ikegami (Patriarch) on Jul 29, 2009 at 16:14 UTC

    Thanks.. eval works perfectly.

    Not really. Why cause an error and then silence *all* errors when it's easier to not cause it in the first place?

    my ($cretime) = eval { stat("$SPOOL/$file")->ctime } or next; push @files, [ $cretime, $file ];
    vs
    my $stat = stat("$SPOOL/$file") or next; push @files, [ $stat->ctime, $file ];

    I used ctime as I want the time that the file was added to the directory by another script.

    ctime definitely doesn't return what you want.

    $ perl -MFile::stat -le'print "".localtime( stat("a")->ctime )' Wed Jul 29 12:13:21 2009 $ chmod u+r a $ perl -MFile::stat -le'print "".localtime( stat("a")->ctime )' Wed Jul 29 12:13:46 2009
Re^2: I don't want to die
by thunders (Priest) on Jul 29, 2009 at 17:47 UTC
    As ikegami points out, UNIX based systems don't actually store creation time anywhere. A better bet is usually to have the script that adds the files to the directory append the timestamp to the end of the file name.