Check fileage with -M when path contains a point?

M

Math55

hi, i have this program. why cant i check the age of a file with -M?

---
use File::Basename;
$path="/home/raid/golchert/.cxoffice/dotwine/filelist.dat";
#$path="/home/raid/golchert/Downloads/CD Control QE 1.0.1.12.exe";

chdir (dirname($path));
$relFile= (fileparse($path));
$rf.="/".$relFile;

print "\n age of $path = ".(-M $rf). "\n" if (-M $rf <=100 && !(-d
$rf));

---

maybe you have to change to a pth that contains a point at your
system. i tried with absolute and relative path, both did not
work:-(...


THANKS:)
 
J

J. Gleixner

Math55 said:
hi, i have this program. why cant i check the age of a file with -M?

---
use File::Basename;
$path="/home/raid/golchert/.cxoffice/dotwine/filelist.dat";
#$path="/home/raid/golchert/Downloads/CD Control QE 1.0.1.12.exe";

chdir (dirname($path));
$relFile= (fileparse($path));
$rf.="/".$relFile;

print "\n age of $path = ".(-M $rf). "\n" if (-M $rf <=100 && !(-d
$rf));

---

maybe you have to change to a pth that contains a point at your
system. i tried with absolute and relative path, both did not
work:-(...

print the value of $rf and you should see your error.

No need doing a chdir, unless it's needed for something else, a -M $path
works fine.
 
T

Tad McClellan

Math55 said:
why cant i check the age of a file with -M?


Because the file is not where you think it is.

It is someplace else.

---
use File::Basename;
$path="/home/raid/golchert/.cxoffice/dotwine/filelist.dat";
#$path="/home/raid/golchert/Downloads/CD Control QE 1.0.1.12.exe";

chdir (dirname($path));


What if that fails?

You should check to see if you actually got what you asked for:

chdir(dirname $path) or die "could not chdir() $!";

$relFile= (fileparse($path));
$rf.="/".$relFile;

/filelist.dat
and
/home/raid/golchert/.cxoffice/dotwine/filelist.dat

are (probably) not the same file.

The 1st one likely does not exist (and that is the one you are looking at).

print "\n age of $path = ".(-M $rf). "\n" if (-M $rf <=100 && !(-d
$rf));


Huh?

You cannot "change to a path". What did you mean there?

Did you mean "change to a directory" instead?

You are not required to do anything to your cwd in order to do
a filetest such as -M, so why are you (attempting to) change
your cwd?

i tried with absolute and relative path,


Show us what you have tried.

The code you've shown does not attempt to use a relative path, and
the absolute path that it tries is not the correct absolute path.

both did not
work:-(...


Then fix them.
 
M

Math55

Because the file is not where you think it is.

It is someplace else.




What if that fails?

You should check to see if you actually got what you asked for:

chdir(dirname $path) or die "could not chdir() $!";



/filelist.dat
and
/home/raid/golchert/.cxoffice/dotwine/filelist.dat

are (probably) not the same file.

The 1st one likely does not exist (and that is the one you are looking at).




Huh?

You cannot "change to a path". What did you mean there?

Did you mean "change to a directory" instead?

You are not required to do anything to your cwd in order to do
a filetest such as -M, so why are you (attempting to) change
your cwd?




Show us what you have tried.

The code you've shown does not attempt to use a relative path, and
the absolute path that it tries is not the correct absolute path.




Then fix them.

hi, i tried like that:

print "\n age of $path = ".(-M $path). "\n" if (-M $path <=100 && !(-d
$path));

that was my first try. when $path contains something like that:

$path="/tmp/hello.txt" it works fine, but as soon as there is a point
like the path i mentioned before -M fails....

:-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top