http://www.perlmonks.org?node_id=1048195


in reply to Calculating/adding byte counts of array elements

You are changing the array and using the changed value to count the number. Do not store the output in the array you are using to count the length:
#!/usr/bin/perl use warnings; use strict; my @array = ('Hello, my name is John', 'How are you?', 'blah (blah)', ); my $count = 0; for my $string (@array) { printf "%08d %s\n", $count, $string; $count += length $string; }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ