s/ ( # Match and backreference to either (?: Perl| # one or perl| # another way PERL| # to spell [Pp][Ee][Rr][Ll] # perl )| # or (?: Java| # one or java| # another way JAVA| # to spell [Jj][Aa][Vv][Aa] # java ) ) / # and replace it with lc($1) eq "perl" ? "$1 looks like a nice language to me" # this when perl is found :lc($1) eq "java"? "I don't know $1 very well" # or this when java is found :"I do not wish to consider $1" # or this when something else is found. /ex;