Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: File "rename" error in renaming a file.

by Marshall (Canon)
on Oct 11, 2022 at 20:23 UTC ( [id://11147357]=note: print w/replies, xml ) Need Help??


in reply to File "rename" error in renaming a file.

First suggestion would be to put more info in your error message:
rename $tempfile, "tempdir/".$new_filename or die "Cannot rename $tempfile to tempdir/$new_filename" $!";
You are renaming an open file. This is indeed allowed, but in this code, I see no need and would avoid that.
while ( <$attach> ) makes no sense because $attach is a text string - what you are trying to do is not at all clear.

Update: Also add use strict; use warnings to your code. If you had done that you will see that while ( <$attach> ) produces the error of attempted read on an unopened file handle.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-24 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found