On 07/02/2014 01:11, Sam wrote:
The oreilly "Learning Perl" teaches one to use the ampersand when calling subroutines, which most perl'ers will disagree with. I did it for years with out even questioning it until it bit me because I had read that book.
I believe that most of the recent dislike of Perl comes from its use of sigils for everything. The original design was a result of Larry Wall's linguistic background, so his sigils were a way of expressing the plurality of value in the same way that we add a suffix `s` to most nouns to show a plural, or `ly` do denote an adverb. It's a nice idea, and is very comfortable once you are used to it, but it can look kinda crazy when you're used to bare variable names. I believe it's much nicer than the awful Hungarian Notation, which comes up with stuff like `arru16Ids` for an array of unsigned sixteen-bit identifiers. The move to object-orientation in Perl 5 rather messed this idea up, as it didn't make sense to call methods as `&{ $object->method }`, so the requirement for the ampersand was dropped in ordinary subroutine calls as well as method calls. I dislike Learning Perl for other reasons: paticularly that, despite being a senior partner of Stonehenge, on whose courses the book is based, doesn't seem to comprehend the problems that people have with learning and understanding Perl. However, later editions of Learning Perl include this section http://hellolixian.tumblr.com/post/5569953537/omitting-the-ampersand that goes some way to explaining the circumstances where an ampersand is necessary. My rule of thumb is that you should use the ampersand if you are treating the subroutine as an item of data: you should drop it if you are just calling it as a function. Rob --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/