On Tue, Mar 10, 2009 at 11:19, howa <howac...@gmail.com> wrote: > Hello, > > Consider the code: > #=================== > > use strict; > > my $a = 'a.jpg'; > > if ($a =~ /(html|jpg)/gi) { > print 'ok'; > } > > #=================== > > > Is the brucket "()" must be needed? Since I am not using back > reference, are there a better way? snip
Since you have no other patterns in the regex you do not need the parentheses. If you had other patterns and wanted to avoid the slowdown associated with backreferences you could use the group-non-capturing parentheses: /foo[.](?:html|jpg)/ -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/