Hi Luca, I haven't tested it, but my suspicion is that your first solution will be faster because regular expressions (which don't contain variables) are only compiled once, while you have a function call for every use of lc.
By the way another alternative might be: $extention =~ /\.bat/i (which would also match BaT, BAt...) Andrew On Wed, Jan 7, 2015 at 7:45 AM, Luca Ferrari <fluca1...@infinito.it> wrote: > Hi all, > this could be trivial, and I suspect the answer is that the regexp > engine is smart enough, but suppose I want to test the following: > > $extention =~ / \.bat | \.BAT /x; > > is the following a better solution? > > $extension = lc $extension; > $extension =~ / \.bat /x; > > In other words, when testing for all-lower or all-upper cases should I > first trasnform to one of them or use a regexp with alternatives? > Any suggestion? > > Thanks, > Luca > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > -- Andrew Solomon Mentor@Geekuni http://geekuni.com/ http://www.linkedin.com/in/asolomon -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/