The substitution operator replaces matching text with new text.

Substitution

substitution.pl
use strict;
use warnings;

my $phrase = ;
my $changed = $phrase;
my $count = ($changed =~ s/red/gold/g);

print "phrase=$phrase\n";
print "changed=$changed\n";
print "count=$count\n";
use strict;
use warnings;

my $phrase = ;
my $changed = $phrase;
my $count = ($changed =~ s/red/gold/g);

print "phrase=$phrase\n";
print "changed=$changed\n";
print "count=$count\n";
use strict;
use warnings;

my $phrase = ;
my $changed = $phrase;
my $count = ($changed =~ s/red/gold/g);

print "phrase=$phrase\n";
print "changed=$changed\n";
print "count=$count\n";
substitution A substitution uses `s/pattern/replacement/` to change matching text.