Link to home
Start Free TrialLog in
Avatar of AlexKhaw
AlexKhaw

asked on

Question on Perl regular expression

Hi Experts,
I'm trying to do is - The program will prompt for enter string and user will enter string. After that it will compare the inputed string with the contain in 'str.tbl'.
'str.tbl' contains list of charather with numbers. The program will exit if the inputed chrather/numbers matches with the contain in 'str.tbl'.

The problem i'm having is this coding does not recognise charathers... it only recognise number...

ex:
'str.tbl' contain
wn7892
dk654
42893
890211
q35672
s123


The coding can only recognise "890211" and "42893".

Any suggestion on the right regular expression to make all contain in 'str.tbl' to be recognised by this program?




#!/usr/local/bin/perl -w

$str = "";
$file = "strfile.bat";

while ()
 {
  print 'Enter String : ';
  ($str = <STDIN>);
 
open(F, "str.tbl") || die "can't open str.tbl $!";
   while(<F>)
   {
   if((/^$str/) && ($str != ""))
      {
        print "Creating String\n";
        open(SRC, ">$file") || die "Unable to open strfile.bat: ($!)\n";
           print SRC "set string=$str\n";
          close(SRC);
      }
   }
   close F;


  last;
 }
ASKER CERTIFIED SOLUTION
Avatar of thenonymous
thenonymous

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AlexKhaw
AlexKhaw

ASKER

Thanks it's working as required!!!
No problem. :)