Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Subroutine to delete one file and copy one file to another

by soonix (Canon)
on Jul 21, 2015 at 12:48 UTC ( [id://1135588]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Subroutine to delete one file and copy one file to another
in thread Subroutine to delete one file and copy one file to another

If I understand your problem correctly, then there's no need for the "delete and copy" dance.
Simply open your tempfile for output and it will automatically get created or truncated.
You already populated your @outagenodes from the data read from your serverlist. So why don't you simply:
open(my $tempfh, ">", $tempfile) or die "couldn't open $tempfile: $!"; print$tempfh @outagenodes or die "error when writing: $!"; close $tempfh or die "huh?? - $!";
BTW I deliberately leave off the space in print$filehandle to remind myself that there's no comma between the file handle and the list...

Log In?
Username:
Password:

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

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

    No recent polls found