while (@a) { shift(@a); if ( is_last_pass() ) { push @a, "foo"; } }