Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by samwyse (Scribe)
on Jul 23, 2012 at 20:17 UTC ( #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.

Comment on Is there any way to successfully use utime in a -pi loop?
Download Code
Re: Is there any way to successfully use utime in a -pi loop? (ARGVOUT)
by tye (Cardinal) 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
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? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-12-25 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls