#!/usr/local/bin/perl -w use strict; my $x = ['1','2',undef,undef,undef,'4']; @$x = map { $_ ||= "" } @$x; while (@$x) { print ">", shift @$x, "<\n"; } ### This gives >1< >2< >< >< >< >4<