Why did you nest the subroutine definition? That's very odd to read and will break if you add lexicals. Also, please do not call subroutines using an ampersand. Write err3() rather than &err3(). Anyway..
If I understand your problem description correctly, you want err3() to only be called when none of your lines match? The way you have it, it will be called once for every time a line does not match. Is that what you want it to do? If not, the following would work:my $had_match = 0; #see? now the sub nesting breaks the code.. while (<TECH>) { if ( /$cnip/ ) { $had_match++; (@npa) = split (/\:/); print "\n", " " x 14, "*" x 60; print "\n", " " x 24, "=" x 40, "\n"; print " " x 24, "NPANXX Line Switch MSR&CUSTGP VMX +\n"; print " " x 24, "$npa[0] $npa[1] $npa[2] $npa[3] $npa[4] $npa +[5]\n"; print " " x 24, "=" x 40, "\n\n"; con(); } } close(TECH); #Close file err3($cnip) unless $had_match;
Makeshifts last the longest.
In reply to Re: Is it there, or is it not?? Quirkiness with error handling.
by Aristotle
in thread Is it there, or is it not?? Quirkiness with error handling.
by defyance
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |