I'm curious why you chose to use map here. I've used arrays of qr!! (Parse Loops with flat text files. (code)), and I also think I have a good sense of when map is appropriate (Sort a long list of hosts by domain (code)). But in some cases, using map seems to be either obfuscation or bloat for the sake of shorter code.my @array = map { qr{$_} } ('^abcd', 'cd[ef]g', 'cat$');
Observe:
Isn't there additional overhead from calling map? Some people are frenzied map lovers. And in some cases, it is the most appropriate way to do something. I just dont see why you used it here.# timtowtdi... foreach ( qw{ ^abcd cd[ef]g cat$ } ) { push @array, qr{$_} }; # shorter still ... push @array, qr{$_} for qw{ ^abcd cd[ef]g cat$ }; # or the way I think is most clear and most sane.... @array = ( qr{^abcd}, qr{cd[ef]g}, qr{cat$} );
Enlighten me?
brother dep.
--
Laziness, Impatience, Hubris, and Generosity.
In reply to Re (2): Hash/Array of Regular Expressions? (code)
by deprecated
in thread Hash/Array of Regular Expressions?
by irom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |