I've used web search, found similarly titled question How many substitutions took place in a Perl s///g? and tried to use it to print the number but have not been able to succeed.
My initial code was
perl -0777 -i.original -pe 's-\r\n-\n-igs' test.txt
When I tried
perl -0777 -i.original -pe "$c=s-\r\n-\n-igs;say qq'$c'" test.txt
I got nothing - no output and no replacements, when I tried
perl -0777 -i.original -pe '$c=s-\r\n-\n-igs;print qq($c\n)' test.txt
(print
similar to other one-liners I used before) I got empty string in standard output but 454847
added as the beginning of file (and proper replacements).
I understand =~
is not needed in my case (What does =~ do in Perl?), so what is wrong with my code? How to print number of replacements made?