I am trying to move to perl (from sed). But how can I replace this sed expression with perl in a similarly short way?
sed -n '/patternmatch/s%stuff%changed%p' file
I need to search for a pattern, and only when the pattern is found, substitute "stuff" with "changed".
The only way I could do it was with an if statement which looks like this
perl -ne 'if ( /patternmatch/ ) { s%stuff%changed%; print }' file
Is it possible to do it as short as with sed? How?
PS: How to do it with python
is here.