#!/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; }