In your second snippet, you still print the last match of the last file, not the last match of each file.
This depends on what is in @completefile, as I previously discussed. I suppose it's also possible the OP wants just one result for all the elements of $exch, in which case the loop nesting should be reversed.
Then why did you proceed by putting the print in an if?
My point was that every iteration should output. If I didn't worry about using warnings, I could have had
foreach my $exch (@exch) { my ($su_adapter, $su_date); foreach (reverse @completefile) { last if ($su_adapter, $su_date) = /^.+\\(.+)_.+\..+?:(.+?)\s-\ +s(.+?)\s.+?\/$exch\s\|.+::(.*Up)\(\)/; } print "Results for $exch: $su_adapter, $su_date\n"; }
which reports the same info with no conditional.
In reply to Re^7: undef a variable for a loop
by kennethk
in thread undef a variable for a loop
by csiepka
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |