Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How to modify words in a line using perl oneliner

by vitoco (Friar)
on Sep 30, 2009 at 14:21 UTC ( #798345=note: print w/ replies, xml ) Need Help??


in reply to How to modify words in a line using perl oneliner

What you are printing is the number of substitutions on each line, ie. "1" when "first" is found, and undef (nothing) when not. A value of "2" would be returned for line 2 if "g" modifier were used.

Prefer -p option instead of -n for this kind of one-liners. In this case, the output should be:

perl -pi.bak -e 's/first/last/' one.txt #verify_custom fleet part=last base=first after base

realizing that "g" modifier is missing if both "first" words must be changed at the same time.


Comment on Re: How to modify words in a line using perl oneliner
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-07-07 23:04 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 (93 votes), past polls