in reply to Re: Using -M to test age of file
in thread Using -M to test age of file

Try using stat

Why? You seem to presume that stat and -M are not intimitely related? In fact -X just calls stat and caches the unused result fragments in the _ magical var - yes it is called _ so you can do this:

$exist = -e $blah; # calls stat, returns -e , caches result $dir = -d _; # takes the last stat (ie $blah) returns -d value $file = -f _; # etc

The problem is a path issue, the solution is:

my $fileAge = -M $fileName || die "Can't stat $fileName $!\n"

The error will be No such file or directory Solution full path. Yes you can make relative work but that is an exercise for the reader.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Re: Using -M to test age of file
by sauoq (Abbot) on Aug 22, 2003 at 17:07 UTC
    In fact -X just calls stat and caches the unused result fragments in the _ magical var - yes it is called _ so you can do this:

    Just to clarify, caching the results isn't peculiar to the filetest operators; stat() itself caches the results too.

    -sauoq
    "My two cents aren't worth a dime.";