$line = "one two three four four SIX"; $line =~ s/two/six/; $line =~ s/four/ten/g; $line =~ s/th(re)e/whe$1/ if ($line =~ /six/i) { }