On 3/10/09 Tue Mar 10, 2009 8:41 PM, "howa" <howac...@gmail.com> scribbled:
> Hi, > > On Mar 11, 1:16 am, nore...@gunnar.cc (Gunnar Hjalmarsson) wrote: >> >> I would do: >> >> if ( $a =~ /\.(?:html|jpg)$/i ) >> >> Please readhttp://perldoc.perl.org/perlretut.htmland other appropriate >> docs. > > Read the doc, but how to negate the "Non-capturing groupings" ? > > use strict; > > my $a = 'a.gif'; > > if ($a =~ /^(?:html|jpg)/gi) { > print 'not html or jpg'; > > } That will test if $a starts with 'html' or 'jpg'. To test for a non-match, use the !~ operator: If( $a !~ /(?:htm|jpg)$/gi ) { print "not html or jpg\n"; } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/