in reply to Re: How & why does this work?
in thread How & why does this work?

I agree. Instead of iterating over an array you modify this way, do it another way:

while ( defined( my $path = shift @all_paths ) ) { # ...
Update: ...but be aware that this leaves @all_paths empty.