#!/usr/bin/perl -w use strict; # updated: Assuming you use strict and warnings :) my @a = (1..10); undef $a[3]; foreach (@a) { print $_ if defined($_); }