Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Calculating/adding byte counts of array elements

by Happy-the-monk (Monsignor)
on Aug 07, 2013 at 07:41 UTC ( #1048276=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Calculating/adding byte counts of array elements
in thread Calculating/adding byte counts of array elements

Initializing $count as a numeric string with a bunch of leading zeros will see the leading zeros vanish after the first numeric operation 'numifies' the scalar even if it's an operation with zero!

So do not numify it but use Perl's little quirks to do the trick:

perl -wMstrict -le 'my $count = "00000000"; print qq{"$count"}; ++$count for 1 .. 42; print qq{"$count"};'

Cheers, Sören

Créateur des bugs mobiles - let loose once, run everywhere.
(hooked on the Perl Programming language)


Comment on Re^3: Calculating/adding byte counts of array elements
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-12-22 01:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (110 votes), past polls