in reply to [SOLVED] copying a file with .bak extension

If you run that script with  perl -i.bak YOURSCRIPT or just put

#! /usr/bin/perl -i.bak

As the first line of the script it should automatically save the backup copy and write output into the original file.

Replies are listed 'Best First'.
Re^2: copying a file with .bak extension
by Anonymous Monk on Nov 07, 2012 at 18:43 UTC

    Nevermind, it was in the wrong format. Should be this:

    #! /usr/bin/perl -i[.bak]

    but now it still doesn't make a copy, or at least I don't see it in my directory.

Re^2: copying a file with .bak extension
by jaffinito34 (Acolyte) on Nov 07, 2012 at 18:37 UTC

    I added that to the top and now at the command line, I run the file...

    ~$ fileName textfile.txt

    it returns this:

    Unrecognized switch: -.bak (-h will show valid options).

    I checked out the valid options and -i should work but for some reasons it isnt.

Re^2: copying a file with .bak extension
by Lotus1 (Vicar) on Nov 07, 2012 at 19:20 UTC

    I tried this but it doesn't work. It clears the original file and prints the copywrite line to the command line. Seems that it has to do with the way <> works with the -i option. See my node below.