Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Looping through a file, reading each line, and adding keys/editing values of a hash

by Anonymous Monk
on Dec 05, 2013 at 20:16 UTC ( [id://1065832]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Looping through a file, reading each line, and adding keys/editing values of a hash
in thread Looping through a file, reading each line, and adding keys/editing values of a hash

There are different schools of thought there. I strongly favour the postincrement.
  • Comment on Re^3: Looping through a file, reading each line, and adding keys/editing values of a hash

Replies are listed 'Best First'.
Re^4: Looping through a file, reading each line, and adding keys/editing values of a hash
by GrandFather (Saint) on Dec 05, 2013 at 20:47 UTC

    I know its strongly favoured by many. I don't understand why.

    My strong preference is to use pre-increment where possible so the increment operator is more easily seen (trailing stuff is more easily ignored). But maybe I'm missing something important about the post-increment?

    A very minor consideration may be that the post-increment could be slower for some implementations that the pre-increment. The difference is so slight that it would be exceptionally unusual for that to be a consideration.

    True laziness is hard work
      In void context, Perl agrees with you:
      $ perl -MO=Deparse -e '$x++' ++$x;
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1065832]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-24 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found