Hacker News new | ask | show | jobs
by cmhamill 4595 days ago
Does anyone know if there's any similar ability in Perl 5?
2 comments

Yup. It's called 'fields': http://perldoc.perl.org/fields.html

I echo what they said in that post, though: don't prematurely optimize. If you find you have tons of objects and need the RAM or you're actually paying a premium for hash accesses, then fields can save you some effort... but if you've a small use case, don't bother.

Perl is better at sharing memory for hash keys by default, this particular problem might not show up enough for your use cases.