"Selector, Lev Y" <[EMAIL PROTECTED]> writes:
> Hello,
>
> What would be a more elegant (short) way to express the following:
>
> while ($choice = uc <>) {
> $choice =~ s/(^\s+|\s+$)//g;
> $choice = 'Y', last if ($choice =~ /^Y?$/);
> $choice = 'N', last if ($choice =~ /^N$/ );
> }
>
> As you see, it is an infinite loop which wouldn't let you out unless you do:
>
> 'y','Y',<ENTER> - 'Y'
> 'n','N' - 'N'
>
>
How about this?
while(<>) {
s/^\s*([yn])?\s*$/$choice=uc$1||"Y";last/ei;
}
--
Scott E Kullberg --><-- [EMAIL PROTECTED]
When I am working on a problem I never think about beauty. I only think
about how to solve the problem. But when I have finished, if the
solution is not beautiful, I know it is wrong. - Buckminster Fuller