use 5.10.0; my @list = qw(one two three); while ( defined( my $element = shift @list ) ) { } continue { if ( defined $element ) { say $element; } if ( !@list ) { say "We've now finished processing the while loop"; } } #### one two three We've now finished processing the while loop