use warnings; use strict; use Data::Dump; my @testarray = ([10,20],[30,40]); dd "A", @testarray; foreach (@testarray) { dd "B", @testarray; while ( ) { dd "C", @testarray; } dd "D", @testarray; } dd "E", @testarray; __DATA__ hello world #### ("A", [10, 20], [30, 40]) ("B", [10, 20], [30, 40]) ("C", "hello\n", [30, 40]) ("C", "world\n", [30, 40]) ("D", undef, [30, 40]) ("B", undef, [30, 40]) ("D", undef, undef) ("E", undef, undef)