$x=0; $dont = pop @fields; foreach $field (@fields){ # and so on...do something with $dont or don't } push(@fields, $dont);