in reply to Is it there, or is it not?? Quirkiness with error handling.
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Is it there, or is it not?? Quirkiness with error handling.
by dmmiller2k (Chaplain) on Jul 12, 2002 at 13:07 UTC | |
by tye (Sage) on Jul 12, 2002 at 20:47 UTC | |
by dmmiller2k (Chaplain) on Jul 18, 2002 at 19:45 UTC | |
|
Re: Re: Is it there, or is it not?? Quirkiness with error handling.
by defyance (Curate) on Jul 11, 2002 at 23:48 UTC | |
by Aristotle (Chancellor) on Jul 14, 2002 at 21:59 UTC |