Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: utime for symbolic links

by choroba (Archbishop)
on Apr 15, 2020 at 13:48 UTC ( #11115572=note: print w/replies, xml ) Need Help??


in reply to utime for symbolic links

It seems such an option is not present in File::Touch. I can't find it in any other module, either (but my CPAN searching skills are below average, I usually can't even find a module I've used).

But what you want is easy to implement using plain Perl functions: instead of touching the old symlink, create a new one and rename it over the old one:

#! /usr/bin/perl use strict; use warnings; use File::Touch qw{ touch }; sub show_stat { system qw( stat file link ); } unlink qw( file link new_link ); touch('file'); symlink 'file', 'link'; show_stat(); sleep 1; symlink 'file', 'new_link'; rename new_link => 'link'; show_stat();

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: utime for symbolic links
by shamlin (Initiate) on Apr 15, 2020 at 15:19 UTC
    Your example sets the atime/mtime to current time. I need to set the atime and mtime of the link to a specific value. I updated my question to be more clear.

      The documentation seems clear enough, no?

      atime => $time
      
          If defined, use this time (in epoch seconds) instead of current time for access time.
      
      mtime => $time
      
          If defined, use this time (in epoch seconds) instead of current time for modification time.
      
      
        But it changes the atime and mtime of the linked file, not the link itself.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11115572]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2021-10-28 09:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (96 votes). Check out past polls.

    Notices?