Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2018-02-25 10:29 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (312 votes). Check out past polls.