Remix.run Logo
spauldo 7 days ago

To be fair, this isn't what normal Perl usually looks like. Perl allows you to write like this but most people don't. This is more like Duff's Device in that it works and it's clever and you'd can anyone who put it in production code.

That's not to say that idiomatic Perl doesn't have its quirks and oddities - Perl idioms do throw off people who aren't used to them. But this is a bit far even for Perl.

kilna 2 days ago | parent | next [-]

If the production code has to be maximally performant, you'd want the transform. It doesn't copy data around with a bunch of needless assignments. Pipelining the extract/sort/reconstitute in this manner is absolutely the right thing to do in production if production requirements are to keep it fast and with a small footprint. There's no excuse for not commenting it, but strictly-code-speaking there's no reason not to use this for production if the requisite needs are there.

dale_glass 7 days ago | parent | prev [-]

I've definitely seen it in production code, but it was a good deal after 1994.

By then it was a commonly known technique, so it was a pattern a Perl dev would be expected to recognize.