Hacker News new | past | comments | ask | show | jobs | submit login

Ive only used Perl for one story at work but I don't fully grok yet why we $ a @ or a %

Getting a hash passed by ref to a sub was a true syntactic challenge that I haven't experienced in a different language. Have to say though, using regex in Perl is chef's kiss




Because an array is a list of scalar, and an hash a map of scalars. If you want to access a scalar inside the list, you write $a[1], which means "the scalar at the first position of list @a". If it was @a[1] it would have been inconsistent, because then a @ expression would have returned a scalar and not a list.




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

Search: