in reply to Inline substitution regex

As you can read in Search and replace in perlretut, substitution returns the number of substitutions, so that is what you are passing to print.

As an example,

#!/usr/bin/perl use strict; use warnings; my $string = 'I like cats. I think cats are nice.'; print $string =~ s/cat/dog/g;