#!/usr/local/bin/perl -w $cnip = $ENV{'QUERY_STRING'}; print "\n Look Up NPANXX Info"; print "\n =============================="; print "\n Please enter NPANXX:_______\b\b\b\b\b\b\b "; chomp($cnip=); if($cnip =~ /\d{6}/){ @datb = `cat tech3 | grep $cnip`; #You could do this a a file open and grep the contents... it would be more portable and perlyer :) @cnip = $cnip; #printing the info foreach $datb (@datb){ @cnip = split (\/\:/, $datb); print "\n ========================================\n"; print " NPANXX Line Switch MSR&CUSTGP VMX"; print " $cnip $cnip[1] $cnip[2] $cnip[3] $cnip[4] $cnip[5]"; print " ========================================\n\n"; } @datb = `cat tech3 | grep $cnip`; @cnip = $cnip; #printing the info foreach $datb (@datb){ @cnip = split (\/\:/, $datb); print "\n ========================================\n"; print " NPANXX Line Switch MSR&CUSTGP VMX"; print " $cnip $cnip[1] $cnip[2] $cnip[3] $cnip[4] $cnip[5]"; print " ========================================\n\n"; } } else { ### you has this left bracket way up under your 'if' print "\nValid NPANXX not entered!\n"; }