Welcome to the Monastery | |
PerlMonks |
Re: Re: Re: I think I'm close...by grummerX (Pilgrim) |
on Mar 01, 2002 at 21:08 UTC ( [id://148683]=note: print w/replies, xml ) | Need Help?? |
The /g is Perl's global match modifier. In this case, you're only looking for a single match, so you don't need it.
I would also suggest taking the approach VSarkiss uses below and anchoring your regex: if ($question =~ /^y/i) ...works great for all concerned, while this: if ($question =~ /(yes|y)/i) ...not only matches, "yes" and "y", but also matches "maybe", "not necessarily", "no way", "definitely not", and "/me rolls eyes". -- grummerX
In Section
Seekers of Perl Wisdom
|
|