> -----Original Message-----
> From: Paul Makepeace [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 05, 2002 1:48 PM
> To: Selector, Lev Y
> Cc: Fun With Perl
> Subject: Re: elegant solution
>
>
> 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*$/;
That doesn't do the same thing though because the default value of $choice
is Y (in case of an empty line, or a line with spaces only). So, must change
this to:
$choice = $1 || 'Y', last if $choice =~ /^\s*(N|Y?)\s*$/;
--Ala