How Well Can You Read Documentation?

(I was going to call this post “How well do you understand context?” but I think this title is more accurate).

I just saw someone recommending this code:

Looks sensible enough, doesn’t it? But it isn’t. What’s the hidden inefficiency?

7 thoughts on “How Well Can You Read Documentation?

  1. Huh.

    I don’t think that’s a sane behaviour for reverse in scalar context (only ever used it with a single argument in scalar context), but I’ll be damned if I can come up with a better alternative.

      1. Why does reverse $string return the original string, but an assignment e.g. : $reversed = reverse $string store the reversed string in the lvalue?

  2. late joining the party. SOme of these ‘dwimminess’ features make me a bit uncomfortable. I feel that if c gives me ‘fred’ then maybe it’s not very /useful/, but at least it’s consistent with my simple user model of the language. When convenience measures like making that result be ‘derf’ are mixed into the language, then it seems to me kind of like encountering an irregular verb in a natural language: it may make life easier on this one occasion for somebody but the whole edifice gets just a bit more complicated … adding to the meme that Perl is ‘too hard’.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.