#!/usr/bin/perl -w @t = qw( aaaa bbbb ccccccc dddddd ); $i = -1; # the 2nd semicolon is not required, but adds clarity @n = map {$i+=2; if ($i%5==0){$i+=2}; $i." ".$_} @t; print map {$_."\n"} @n;