Check fileage with -M when path contains a point?

Discussion in 'Perl Misc' started by Math55, Jul 11, 2003.

  1. Math55

    Math55 Guest

    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:)
     
    Math55, Jul 11, 2003
    #1
    1. Advertising

  2. Math55

    J. Gleixner Guest

    Math55 wrote:
    > 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.
     
    J. Gleixner, Jul 11, 2003
    #2
    1. Advertising

  3. Math55 <> wrote:

    > 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));
    >
    > ---
    >
    > maybe you have to change to a pth that contains a point at your
    > system.



    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.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jul 12, 2003
    #3
  4. Math55

    Math55 Guest

    (Tad McClellan) wrote in message news:<>...
    > Math55 <> wrote:
    >
    > > 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));
    > >
    > > ---
    > >
    > > maybe you have to change to a pth that contains a point at your
    > > system.

    >
    >
    > 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.


    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....

    :-(
     
    Math55, Jul 13, 2003
    #4
  5. Math55 <> wrote:


    [ snip 70 lines of full-quote ]

    [ I have asked you to please stop doing that ]


    > hi,


    bye.

    *plonk*


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jul 14, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Dyer
    Replies:
    5
    Views:
    665
  2. Maciej Sobczak
    Replies:
    9
    Views:
    558
    Roger Binns
    Apr 25, 2004
  3. Replies:
    5
    Views:
    954
    X-Centric
    Jun 30, 2005
  4. Saraswati lakki
    Replies:
    0
    Views:
    1,372
    Saraswati lakki
    Jan 6, 2012
  5. bob smith

    rectangle contains point

    bob smith, Oct 5, 2012, in forum: Java
    Replies:
    4
    Views:
    383
    bob smith
    Oct 5, 2012
Loading...

Share This Page