#!/usr/bin/perl use 5.016; use warnings; # 1048190 my @arr = ("Hello, my name is John", "How are you?", "blah (blah)", "", "blivitz is in the last line.", ); my $count = 0; for my $line(@arr) { say $count . " " . $line; $count += length($line); } #### C:\>1048190.pl 0 Hello, my name is John 22 How are you? 34 blah (blah) 45 45 blivitz is in the last line.