On Thu, Sep 05, 2002 at 01:37:05PM -0400, Selector, Lev Y wrote: > 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$/ );
How about here, $choice = $1, last if $choice =~ m/^\s*(N|Y?)\s*$/; ...and drop the two lines above it. I'd personally use $_ but that's your $choice :-) Paul -- Paul Makepeace ....................................... http://paulm.com/ "If your fighting technique is unstoppable, then I would wonder." -- http://paulm.com/toys/surrealism/