in reply to foreach gotcha!
You're declaring a lexical variable outside of the loop. You use implicit aliasing to the magic $_ with your foreach statement. Then, you copy the contents of $_ to $domain_file.my $domain_file; FILE: foreach (@domain_files) { $domain_file = $_;
Hmm. What happens when you leave the loop via last? $domain_file is still in scope, so it will still contain whatever it contained before you broke out of the loop.
I'll go double or nothing that the following will work better for you:
FILE: foreach my $domain_file (@domain_files) {
|
|---|