in reply to Re: Hash/Array of Regular Expressions?
in thread Hash/Array of Regular Expressions?
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Why use map here? (re: Hash/Array of Regular Expressions?)
by bikeNomad (Priest) on Jun 24, 2001 at 20:19 UTC | |
Re: Re (2): Hash/Array of Regular Expressions? (code)
by risacher (Beadle) on Jun 24, 2001 at 20:41 UTC | |
Re: Re (2): Hash/Array of Regular Expressions? (code)
by Aighearach (Initiate) on Jun 25, 2001 at 01:37 UTC |