This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Perl and the fly likes perl  String find and replace - count ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Languages » Perl
Bookmark "perl  String find and replace - count ?" Watch "perl  String find and replace - count ?" New topic
Author

perl String find and replace - count ?

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1376
perl -pi -e 's/sample1/sample2/g' *.* replaces string value sample1 with sample2 globally. How do i add count (number of times sample1 string replaced) ?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11351
    
  16

perlmonks is always a great place to search. I found this, which appears to be your exact question.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
GeeCON Prague 2014
 
subject: perl String find and replace - count ?