re: What language features/concepts do insiders of the language love and outsiders hate? VIEW POST

VIEW PARENT COMMENT VIEW FULL DISCUSSION

I first tried to teach myself to program using Perl. It ha(s|d) the most complete documentation with an expansive library of books and tutorials. I learned a lot about learning to program and asking good questions because of Perl.

On a Monday, I was asked if I knew Perl. I replied that I knew several languages it was based on (awk, sed, Bash) but not Perl exactly. They said "Cool. Your interview is this Thursday. Know Perl by then."

I spent three days on perldoc.perl.org to ace that interview, and found the documentation to be equal parts blunt, refreshing, informative, and horrifying.

Case in point: "If any part of LIST is an array, foreach will get very confused if you add or remove elements within the loop body, for example with splice. So don't do that."

It's common knowledge that modifying the list you're iterating over is a bad idea in almost any language. Safe languages have ways to detect this situation and prevent errors (like Java's ConcurrentModificationException). Unsafe languages trust you to know better. Perl... helpfully tells you not to do that.

I've certainly pushed onto the tail end of a looping array in Perl. You just need to be careful.

But I don't do it anymore.

code of conduct - report abuse