Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Is there any way to successfully use utime in a -pi loop?

by samwyse (Scribe)
on Jul 23, 2012 at 20:17 UTC ( [id://983231]=perlquestion: print w/replies, xml ) Need Help??

samwyse has asked for the wisdom of the Perl Monks concerning the following question:

The following doesn't generate any errors, but if it's changing the time stamps then something's changing them back immediately. Can anyone help?
#!/usr/bin/perl -pi.bak # Strip DOS CR chars, hopefully without affecting mtime s/\cM//g; if (eof) { @times = (stat($ARGV.$^I))[8,9]; close ARGV; utime @times, $ARGV or warn; }
This is perl, v5.8.8 built for aix-thread-multi, if it matters.

Replies are listed 'Best First'.
Re: Is there any way to successfully use utime in a -pi loop? (ARGVOUT)
by tye (Sage) on Jul 23, 2012 at 21:20 UTC

    You need to close the output file handle there, ARGVOUT. No, I didn't test if that was enough to make it work, though.

    - tye        

      D'oh!!! Thanks, I don't know how I missed that. Well, really, I do. I my scripting confirming that $ARGV was the name of the output file, so obviously ARGV had to be the file itself, right?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-03-28 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found