sub trim { return map { s/\.mp3\z//; $_ } sort @_; } # and decorate it in the 'client' print DB map {"$_\n"} trim(@files);