Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Does anyone know if there's any similar ability in Perl 5?


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.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: