CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [ChicagoOutfit] A URL validate function... what's wrong?: Edit Log



KevinR
Veteran


Jun 17, 2009, 2:33 PM


Views: 1144
Re: [ChicagoOutfit] A URL validate function... what's wrong?

Lets run a test of your code:


Code
my @allow_redirect_to	= qw(http://www.yahoo.com http://www.google.com); 
my @urls = qw(http://www.yahoo.com http://www.google.com http://www.msn.com);
foreach my $url (@urls) {
if (check_url_valid($url) ) {
print "$url is Good\n";
}
else {
print "$url is Bad\n";
}
}
sub check_url_valid {
my $val = shift;

foreach (@allow_redirect_to) {
return 1 if ($val eq $_);
}

return 0;
}


output:

http://www.yahoo.com is Good
http://www.google.com is Good
http://www.msn.com is Bad

As I said, this snippet of code it working properly so the problem is elsewhere in your script.
-------------------------------------------------


(This post was edited by KevinR on Jun 17, 2009, 2:34 PM)


Edit Log:
Post edited by KevinR (Veteran) on Jun 17, 2009, 2:34 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives