in reply to Re^5: undef a variable for a loop
in thread undef a variable for a loop

In your second snippet, you still print the last match of the last file, not the last match of each file.

I disagree with you point about printing

Then why did you proceed by putting the print in an if?

Replies are listed 'Best First'.
Re^7: undef a variable for a loop
by kennethk (Abbot) on May 15, 2009 at 19:43 UTC
    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.

      My point was that every iteration should output.

      I never said the if shouldn't have an else.

      This is the second time you talk of disabling warnings (for what appears to be a large scope) and giving unclear output to save an if. That I disagree with.