Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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


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

Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2016-10-27 08:57 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (355 votes). Check out past polls.