in reply to Re: Checking Input using reg exp.
in thread Checking Input using reg exp.

Cool, I got it figured out. Its working great now. Now to make it look a bit perlyer, he he. I've been working with C and Shell progs most of my natural programming life, he he. Here is the working code:

#!/usr/local/bin/perl $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=<STDIN>); if($cnip =~ /\d{6}/){ &npa1 } else{ print "\n Valid NPANXX not entered!\n"; }; sub npa1 { @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"; }; };



I'll make it prettier and stuff, TEAR IT APPART PLEASE!!

Replies are listed 'Best First'.
(shockme) Re: Re: Re: Checking Input using reg exp.
by shockme (Chaplain) on Dec 28, 2001 at 09:30 UTC
    Perltidy will help you clean it up and "make it prettier".

    If things get any worse, I'll have to ask you to stop helping me.

Re: Re: Re: Checking Input using reg exp.
by gav^ (Curate) on Dec 28, 2001 at 19:55 UTC
    You don't need to escape the ':' in the regex.
    @cnip = split /:/, $datb
    will do fine.

    Also using cat & grep seems a bit messy, what about:

    use File::Slurp; @datb = grep { /$cnip/ } read_file('tech3');