#!/usr/bin/perl -w use strict; my @array = qw(0 1 2 3 4 5 6 7 8); print join '_' , grep length, map {$array[$_] if $_ % 2 == 1} (0 .. $#array);