Greetings

This is my first stab at Perl. Please be gentle :-)

I have the following snippet which seems to do what I am trying to do,
namely, check the url field value in a POST request, do a server
redirect (as opposed to browser redirect) if the value is in
safe_destinations array, redirect to start.htm if not.

#!/usr/bin/perl -wT
#
use strict;
use CGI qw(:standard);
my @safe_destinations = ('a.htm', 'b.htm', 'c.htm');
my $destination_url = '/start.htm';
if(param()) {
        foreach (@safe_destinations) {
                if (param('url') eq $_) {
                        $destination_url = '/' . param('url');
                        last;
                }
        }       
}
print redirect($destination_url);

I have two questions
Is there a function to check if an item is in an array, instead of
looping through the array? Can you see a problem with the snippet?
Many thanks for your time.
K.

Reply via email to