I am a beginner in Perl and am trying to construct a script which can replace the occurrences of a particular string in an array some fixed number of times. The no. of times is stored in a variable $count. So when I tried above methodology using a slight modification :
s/oldtext/newtext/$count for @config;, I got a Perl syntax error. I know this is very naive, but my thinking was that if /g at the end makes this substitution for all the occurrences of oldtext, then /$count at the end should replace the oldtext by newtext by $count no. of times!
Do I have to construct a loop by reading the array @config line by line and then replace $count number of times? Actually how do I construct such a loop?