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...

'str.tbl' contain

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 $!";
   if((/^$str/) && ($str != ""))
        print "Creating String\n";
        open(SRC, ">$file") || die "Unable to open strfile.bat: ($!)\n";
           print SRC "set string=$str\n";
   close F;

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I do not know much Perl, so I am not really sure, but I think this should solve the problem.

Remember that, in the second inner condition, you are comparing strings, so instead of:

> if((/^$str/) && ($str != ""))


> if ((/^$str$/) && !($str =~ /^$/))

Hope this helps. :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlexKhawAuthor Commented:
Thanks it's working as required!!!
No problem. :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.