my @list = ('foo', 'bar', undef, 'batz'); my @clean_list; for (@list) {if (defined) { push (@clean_list, $_); } } @list = @clean_list;