NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Maintainability (Score:1)
Paradigm shifts often take time.
Re:Maintainability (Score:1)
Here! Here!
The problem with functional code is that most fresh meat, er, new hires/newbies won't grok what's going on in the code. By using procedural idioms over the functional ones, your code is more likely to be understood by others (and maybe even you) in the future. Using language neutral idioms in public Perl code goes a very long way to squashing Perl's "unmaintainable, spaghetti code" reputation.
Does that mean eschewing
mapandgrepall together? I don't think so. It is better to limit the use ofRe:Maintainability (Score:2)
Nice and succinct, and I think easy to understand (though I should probably be using File::Spec for portability, but *shrug*). I also partly wish you could do filters like this, sort of like SAX pipelines, so I could do something like:
I'm sure pdcawley will now pipe in how Perl 6 will be able to do this via hyper operators or something
Reply to This
Parent
Re: Fav. map/grep idioms (Was: Maintainability) (Score:1)
@stuff = sort keys %{{ map {$_ => undef} @stuff }};
gets a sorted list of uniq entries in @stuff.
I always use undef instead of 1 for insignificant hash values because it just *seems* like it should be more efficient. I've never benchmarked any stress-tests though.
-matt