my $index = 0; foreach (@list) { last if $pos eq $_; $index++; }; foreach $i (0..$#list) { print( ("*"," ","|")[ $i <=> $index ], " $list[$i]\n"); };