Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: Unix rename behaviour

by BrowserUk (Patriarch)
on May 03, 2006 at 10:04 UTC ( [id://547103]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Unix rename behaviour
in thread Unix rename behaviour

So the answer is "neither - rename closes the filehandle".

I think you missed the bit about "... two concurrent (Perl) processes ..." and "... when the second process next reads via it's open handle ..."

A better test would be

#!/usr/bin/perl use strict; use warnings; open OUT, '>', 'junk.1' or die $!; print OUT 'X'x 20 . "$_\n" for 1 .. 20; close OUT; open OUT, '>', 'junk.2' or die $!; print OUT 'Y'x 20 . "$_\n" for 1 .. 20; close OUT; open IO, '+<', 'junk.1' or die $!; seek IO, 0, 0; print scalar <IO>; system $^X, '-le', q[ print rename( 'junk.2', 'junk.1' ) ? 'worked' : +'failed']; print scalar <IO>; seek IO, 0, 0; print scalar <IO>; close IO; unlink 'junk.1';

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-19 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found