Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Unlink or rename?

by samarzone (Pilgrim)
on Dec 22, 2010 at 06:39 UTC ( #878445=note: print w/ replies, xml ) Need Help??


in reply to Unlink or rename?

If you don't care for the old data why are you opening the file in append mode? Use '>' for opening file. You have also incorrectly written my where only file name should be. There is no value of a keyword inside double quotes if you are not evaling it. It should be something like

open(my $OUTPUT, '>', "file.txt") or die $!;

Don't forget to close the handle

close($OUTPUT)

Update: As pointed by hossman and Anonymous Monk below, "my file.txt" has no problem as a file name. My assumption was that you were expecting a file named "file.txt"

-- Regards - Samar


Comment on Re: Unlink or rename?
Select or Download Code
Re^2: Unlink or rename?
by Anonymous Monk on Dec 22, 2010 at 06:48 UTC
    You have also incorrectly written my where only file name should be.

    my filename.txt is perfectly valid for a filename :)

Re^2: Unlink or rename?
by hossman (Prior) on Dec 22, 2010 at 06:49 UTC

    "my file.txt" is a perfectly valid filename on many filesystems.

      Agreed. I believed the OP did not want the file name as "my file.txt" and instead he wrote my as a keyword. If it was as a filename then that's perfectly fine.

      Thanks for pointing :)

      -- Regards - Samar

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (18)
As of 2014-12-22 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (119 votes), past polls