# File: subst0.pl # Title: Replace ALL old character(s) with new character(s) $str =~ s/$oldStr/$newStr/g ; # Ask for sentence, new and old character(s) # Author: Mihaela Malita # Input word/sentence? Blaise Pascal # Old character? l # New character? L # Susbtitution done BLaise PascaL print "Input word/sentence? "; $str = ; chop($str); print "Old character? "; $oldStr = ; chop($oldStr); print "New character? "; $newStr = ; chop($newStr); # s stands for substitute $str =~ s/$oldStr/$newStr/g ; # use the operator =~ g stands for global (all) print "Global Susbtitution done= ",$str; # s stands for substitute $str =~ s/a/A/ ; # use the operator =~ substitues only ONCE print "\nOnly first Substitution done= ",$str; ## Check?? $str =~ s/$oldStr{2}/$newStr/ ; # use the operator =~ exit;