in reply to (jeffa) Re: Using File::Find with a bit of elegance
in thread Using File::Find with a bit of elegance

I preach about separation of presentation and content when i discuss CGI scripts, but i unintentionally strayed from that principle with this subroutine:
sub trim { return map { s/\.mp3\z/\n/; $_ } sort @_; }
How? By 'decorating' each filename in the list with a newline. Oops!

Better would be the following:

sub trim { return map { s/\.mp3\z//; $_ } sort @_; } # and decorate it in the 'client' print DB map {"$_\n"} trim(@files);
Of course, the downside is two maps instead of one, but, this is better when making generic, robust, reusable subroutines. Allowing the client to make this decision could very well cut back on the number of modifications required for that subroutine.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)