Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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]
[Discipulus]: when I was used to hand writing I reached a very good level, but chars were ~1mm
[LanX]: choroba: another way of gaining XP is up-voting my posts ... (works always!)
[moritz]: works always, one third of the time! :-)
[LanX]: Bah mine are different. Proof otherwise!
[choroba]: Re: Zen and the art of ignoring XP
LanX with a sufficiently large test sample of 1000 votes
[Discipulus]: LanX XP is a game! look at me.. ;=)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-09-26 11:41 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.