Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Corrector

by jdporter (Canon)
on Dec 02, 2008 at 18:28 UTC ( #727480=note: print w/ replies, xml ) Need Help??


in reply to Re: Corrector
in thread Corrector

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

It also doesn't work. Did you even try it?


Comment on Re^2: Corrector
Download Code
Replies are listed 'Best First'.
Re^3: Corrector
by hossman (Prior) on Dec 02, 2008 at 19:15 UTC

    Nope, didn't give it any thought at all. should be fixed now.

      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... ;-)

        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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://727480]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2015-07-30 00:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls