Perl Shell - A Solution

s/^\s*;\s*// || ! s/^\s*:\s*// && $s

This entire expression is true if (a) the command begins with a semicolon, or (b) the command doesn't begin with a colon and the -s switch was given. These are precisely the conditions under which we'll accept the command as a Unix command. And, under all other conditions, we'll accept it as a Perl command.

Adding in parentheses, which happen to be optional in this case, we see that the first logical connective to be concerned with is the "or" (||):

    s/^\s*;\s*//    ||    ((! s/^\s*:\s*//) && $s)
Note: