Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

perl String find and replace - count ?

 
kri shan
Ranch Hand
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12097
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
perlmonks is always a great place to search. I found this, which appears to be your exact question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic