http://www.perlmonks.org?node_id=1193196


in reply to Replace and substitur in same file

Hi,

Open the source file, checking for success.

Open a destination file, checking for success.

Read source file line by line, make substitutions, write to destination file.

Close files for neatness ( OCD, I can't help myself ).

Check for success everywhere you can.

Start EVERY program with strictures. For at least the next 5 years.

J.C.

Replies are listed 'Best First'.
Re^2: Replace and substitur in same file
by GrandFather (Saint) on Jun 21, 2017 at 09:44 UTC
    Start EVERY program with strictures. For at least the next 5 years.

    Nah. Forever. The cost is nothing and the benefit, just from spotting typos, way out strips the cost of admission.

    Premature optimization is the root of all job security

      Well, in five years, it should be safe to abandon old versions of Perl, and just:

      use 5.012;

      which is better than use strict because it enables strict mode without needlessly loading a module.