while (my $next = shift @queue) { my ($path, $ref) = @$next; ...