my $str="17:43:33:21:23:19:27:6"; my @aux = split /:/, $str; my @ary = map {($aux[2*$_+1]) x $aux[2*$_]} 0 .. @aux/2-1;