in reply to Pattern Substitution..

There are a number of things going wrong here, not least of which is the fact that you are initialising $string1, $string2 and $string3 to an empty string - not what you think.

use strict would have caught this error.

But assuming that you do initialise all of your strings to "good food", the three results you get are "egood food", "ged food" and "geed feed" - which might also confuse you a bit. Let's look at the three regexes in a bit more detail.

s/o*/e/ says "look for zero or more os and convert them to one e". The first place you find zero or more os is at the start of the string, so that is changed to an e.

s/o+/e/ says "look for one or more os and convert them to one e". That finds the oo in "good" and converts them to an e.

s/o/e/g says "find one o and convert it to an e, then repeat that process for every o in the string".

--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me