howa wrote:
Hello,

Consider the code:
#===================

use strict;

my $a = 'a.jpg';

if ($a =~ /(html|jpg)/gi) {
    print 'ok';
}

#===================


Is the brucket "()" must be needed?

Parentheses. What happened when you tried without them? And why the /g modifier?

Since I am not using back reference, are there a better way?

I would do:

    if ( $a =~ /\.(?:html|jpg)$/i )

Please read http://perldoc.perl.org/perlretut.html and other appropriate docs.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to