From: "Chas. Owens" <[EMAIL PROTECTED]>
> On Dec 18, 2007 4:49 PM, Rob Dixon <[EMAIL PROTECTED]> wrote:
> snip
> > if (grep { not /\.mdb\z/ } @ARGV) {
> >    print "All parameters must be MDB files\n";
> >    exit;
> > }
> snip
> 
> Or in Perl 5.10, coming to stores near you soon*, you can use the
> smart match operator:
> 
> @ARGV ~~ /\.mdb\z/
>     or die "All parameters must be MDB files"
> 
> See smart matching in perldoc perlsyn or
> http://search.cpan.org/dist/perl/pod/perlsyn.pod#Smart_matching_in_detail
> 
> * I just checked and in fact it was released yesterday.

I did not install it yet so I can't check but I think you have it 
wrong. According to the docs you point to

   @ARGV ~~ /\.mdb\z/

is equivalent to

   grep /\.mdb\z/, @ARGV

which is true whenever at least one item in the array matches the 
regexp. So it would be

 @ARGV ~~ /\.mdb\z/
     or die "At least one of the parameters must be an MDB file";

Probably not what Rob (or whoever posted the original post) intended.

   grep {not <condition>} @ARRAY 

     is not equivalent to

   not grep {<condition>} @ARRAY 

not even in boolean context.


   @ARGV ~~ /\.mdb\z/
is
   any(@ARGV) =~ /\.mdb\z/
not
   all(@ARGV) =~ /\.mdb\z/

I think there should have been a !~~ operator as well.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to