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

Re^3: Word frequency in an array

by blazar (Canon)
on Jun 11, 2007 at 17:06 UTC ( [id://620538]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Word frequency in an array
in thread Word frequency in an array

Why not start with $x = 0, and then pre-increment instead of post-incrementing $x? In other words, ++$x, instead of $x++.

Indeed. In fact it's also worth reminding incidentally that {pre,post}-{increment,decrement} behave intelligently by first of all not complaining under warnings and, in the case of post-ones, to "coerce to numeric value", that is, to return 0:

errol:~ [19:01:32]$ perl -wMstrict -le 'my $x; print map $x++, (1) x 3 +' 012

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found