Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] touch -r

Expand Messages
  • Smith, Eric - WPAFB/YSXOI
    ... Sounds like you want Perl s utime function. You can set atime and mtime with utime... utime($atime, $mtime, $file); If you only want to change one, you
    Message 1 of 1 , Apr 19, 2000
    • 0 Attachment
      > Does anyone know offhand how to do a "touch -r" from within perl? I
      > want to modify the timestamp of a file, and I'd rather not launch any
      > outside commands... so I'm trying to avoid using "system(...)" or
      > backticks...

      Sounds like you want Perl's "utime" function. You can set atime and
      mtime with utime...

      utime($atime, $mtime, $file);

      If you only want to change one, you can grab the other with stat...

      $mtime = (stat $file)[9];
      utime(time, $mtime, $file);

      HTH,

      - Eric
    Your message has been successfully submitted and would be delivered to recipients shortly.