http://qs321.pair.com?node_id=727486


in reply to Re^3: Corrector
in thread Corrector

Ok, the perl program is now correct... but your calling protocol is still junk. I believe you're going to end up with a solution which is a convoluted mixture of perl and "shell", or else do globbing inside the perl program, not unlike what the OP did. Of course, it wouldn't be nearly so much of a problem on an operating system with a Real Shell... ;-)

Replies are listed 'Best First'.
Re^5: Corrector
by dmorgo (Pilgrim) on Dec 29, 2008 at 01:21 UTC
    Technically correct if the OP's true intention was to replace only the first occurrence of each item in each line where it occurs. I tend to believe the OP probably wanted to replace all occurrences, not just one per line. I know you, jdporter (dmorgo bows) already know what character is missing ;-) but for the OP's benefit, adding a 'g' modifier would do the trick:

    #!/usr/bin/perl -pi s/this/that/g; # substitutes this with that s/one/two/g; # substitutes one with two