Click to See Complete Forum and Search --> : PERL help
rbottner
08-22-2003, 10:58 PM
I had a problem with java and someone recommended PERL. Please help me if you can....
My post is located here:
http://forums.webdeveloper.com/showthread.php?s=&threadid=15530
THANKS!
Jeff Mott
08-23-2003, 12:17 PM
#!/usr/bin/perl -wT
use strict;
use warnings FATAL => 'all';
use CGI;
my $cgi = CGI->new();
my $page_name = $cgi->param('--name of text field--');
$page_name =~ tr/ /+/;
$page_name =~ s/(\W)/sprintf('%%%02X, ord($1))/eg;
print $cgi->redirect("http://www.xyz.com/server/$page_name.htm");
Charles
08-23-2003, 12:58 PM
It doesn't need to be that complicated. My version is only three lines long and that includes the shebang. My is, however, wrong. It should have been a bit shorter yet.
#!user/local/bin/perl
use CGI qw(header redirect param);
print redirect 'http://www.xyz.com/server/'.(param 'number').'.htm';
To get the script running, or any script running, you will need to talk to your server people. There are several things that are server specific. You'll need to know just where the script would go, you'll need permission, you'll need to adjest the first line of the script to reflect the location of the Perl interpreter and you'll need to set the file permissions so that the script will be run.
Jeff Mott
08-23-2003, 01:19 PM
It doesn't need to be that complicatedI believe it does. What if the destination filename has a % symbol? Or a #? It will end up being treated as an escaped character or a fragment anchor. The filename must be URI encoded. And that, aside from strict and warnings, is the only real difference between yours and mine.
Charles
08-23-2003, 04:03 PM
Except that in this case there should not be any troublesome values. We are expecting only digets. But you are right that we should do some validation. I've split one line in two to simplify.
#!user/local/bin/perl
use CGI qw(header redirect param);
my $number = join '', param ('number') =~ m/\d/g;
print redirect "http://www.xyz.com/server/$number.htm";