in reply to conditional regex
print "yes\n" if /^y(?:es)?$/i; [download]
If the expected input is y or yes in a line then following code can be used simply.
while(<>) { print "yes\n" if /(^y$|^yes$)/i; } [download]
while(<>) { print "yes\n" if /^y$/i || /^yes$/i; } [download]
while(<>) { print "yes\n" if /^y$/i; print "yes\n" if /^yes$/i; } [download]
By the way, useless capturing greatly slows down pattern matching.