Simple (for some) Code change

Help please.

The code below reads from the file badurl.txt ie: http://www.test.com and refers to sub routine &no_url

I need the code to do the same but also refer to &no_url when anything occurs after the example http://www.test.com such as http://www.test.com/ or http://www.test.com anything here

# Check for BANNED urls.

open (BANURL, "$basedir/badurl.txt");
@badurl = <BANURL>;
close (BANURL);
     foreach (@badurl) {
     chomp $_;
     $temp = $_;
     $FORM{'url'} =~ tr/A-Z/a-z/;
          if ($FORM{'url'}eq $temp) {
          &no_url;    
     }
}
malkieAsked:
Who is Participating?
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.

bcladdCommented:
So, if I understand your question, you are asking to call no_url for any value in $FORM{'url'} that has a bad url as a prefix? Use regular expressions:

  if ($FORM{'url'} =~ /^$temp/) {
    &no_url;
  }

The ^ anchors the check at the beginning of the string so you might want to clean out leading spaces in the form before running this test.

Hope this helps, -bcl
0

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
TintinCommented:
open BANURL, "$basedir/badurl.txt" or die "Can not open $basedir/badurl.txt $!\n";

while (<BANURL>) {
  chomp;
  no_url() if (/^$FORM{'url'}/i);
}

close BANURL;
0
malkieAuthor Commented:
Works great
God Bless
0
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
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.