jbt424 has asked for the wisdom of the Perl Monks concerning the following question:
The browser address bar will accept the full script with the URL parameter like this: http://webserver/cgi-bin/myscript.pl?URL=http://www.google.com I am new to Perl. I stole this code but it does not do a GET and I think I am using a bad example or one that does not apply to what I need to do: I resolved my issue and code is below.
#!/usr/local/bin/perl use strict; use warnings; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; use URI::Escape; use strictures; use CGI; use URI; my $q = new CGI ; my $url = "httpcandy"; # Process an HTTP request #my @values = $q->multi_param('form_field'); my $value = $q->param('param_name'); print "Content-type: text/html\n\n"; #print "<pre>\n"; # #foreach my $key (sort keys(%ENV)) { # print "$key = $ENV{$key}<br/>"; #} #print "</pre>\n"; my $requested = URI->new( CGI::url() ); $requested->query( $ENV{QUERY_STRING} || $ENV{REDIRECT_QUERY_STRING} ) if url_param(); #print header(), # start_html(), # h1("requested:"), # blockquote($requested), # h1("url:"), # blockquote($value), # h1("nothing else"), # # end_html(); # if ($value =~ /http/) { print "<META HTTP-EQUIV=refresh CONTENT=\"1;$value\">\n"; } else { print "<META HTTP-EQUIV=refresh CONTENT=\"1;URL=http://$value\">\n" +; }; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl CGI redirect
by FreeBeerReekingMonk (Deacon) on May 26, 2015 at 14:53 UTC | |
by Anonymous Monk on May 26, 2015 at 15:12 UTC | |
by jbt424 (Initiate) on May 26, 2015 at 16:32 UTC | |
by FreeBeerReekingMonk (Deacon) on May 28, 2015 at 21:15 UTC | |
by FreeBeerReekingMonk (Deacon) on May 28, 2015 at 21:54 UTC |