I'm having issues. All I'm doing is opening a file, finding the data read by STDIN, and prints the found data to the terminal. If the data is not found, I want it to error out, and write STDIN to a log. This should be simple, but I'm obviously doing something wrong, and can't seem to find the err in my ways.. Please take a look at the below code:
The code does use strict and -w, it declares the var's using use vars qw($var);.
Then err3 sub will put the unfound data from STDIN to a log file like so:sub npa { #This purdy little thing searches the NPA-NXX given to STDIN #Then it prints the happy little output to the terminal. print "\n", " " x 31, "Look Up NPANXX Info\n"; print " " x 27, "=" x 30, "\n"; print " " x 30, "Please enter NPANXX:"; chomp( $cnip = <STDIN> ); if ( $cnip =~ /\d{6}/ ) { &npa1; } else { &err2; } sub npa1 { open( TECH, "</export/home2/knxvcs/knxvcs56/ttu/npalist" ) || die "Oops : $!"; while (<TECH>) { if ( $cnip / ) { (@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; } else { &err3($cnip) } } close(TECH); #Close file } }
sub err3 { #Woah man.. print "\n" x 2; print " " x 20, "Selection Not Found! Press <Enter> to Continue"; <>; open(ERRLOG, ">>/export/home2/knxvcs/knxvcs56/ttu/errlog") || die "Oops : $!"; print ERRLOG "$cnip\n"; close(ERRLOG); system("clear"); menu(); }
This should be so simple, but I don't know what the heck I'm doing wrong!! If it doesn't find any data, it processes what the else tells it to do, and move on happily, or thats the way I think it should go.. It seems that its not finding any of the data, because even if I put something in that I know is in the data file, it sends me to the &err3 sub, and puts the unfound data into the log file. If I comment out else { &err3($cnip) }, it finds the data that it should happily, and moves on. Like I said IT WORKS When I uncomment the else { &err3($cnip) } line, aside from not erroring out if data isn't found....Am I overlooking something simple? If so, go easy on me, I've had a bad day..
Any ideas??
edited: ~Sat Jul 13 16:10:32 2002 (GMT)
by footpad: Added <readmore> tag, per Consideration.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |