Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6725099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:46:01+00:00 2026-05-26T09:46:01+00:00

I have a perl script using CGI. The browser calls it with some parameters.

  • 0

I have a perl script using CGI.

The browser calls it with some parameters.

I want to take those parameters, modify some of them and then send back a redirect with a new querystring representing the modified parameters.

I know that I could do this, like this:

my $cgi = CGI->new()
my %vars = $cgi->Vars
$vars{'modify_me'} .=' more stuff';

my $serialized = join '&', map {$_.'='.$cgi->escapeHTML($vars{$_})} keys %vars;

However, this just feels like it might be missing something. In addition, it doesn’t do anything to handle multivalued parameters. Who knows what else it fails to do.

So, is there a module out there that just deals with this problem? I’m not interested in reinventing a wheel that a more talented wright wrought. Right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:46:02+00:00Added an answer on May 26, 2026 at 9:46 am

    The URI module is your friend. It has a query_form method that takes a hash, hashref or arrayref of parameters and generates a query string from it.

    It will URL Encode your data for you (and note that you do want it URL Encoded and not HTML Encoded).

    So you might have something like:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    use CGI;
    use URI;
    
    my $q = CGI->new;
    
    my @data = map {
            my $name = $_;
            my @values = $q->param($name);
            my $value;
            if (scalar @values == 1) {
                ($value) = @values;
            } else {
                $value = \@values;
            }
    
            if ($name eq "foo") {
                $value = "replaced";
            }
            ($name, $value);
        } $q->param;
    
    my $uri = URI->new('http://example.com/myAlternative.cgi');
    $uri->query_form(\@data);
    
    print $q->redirect(
        -uri=> $uri,
        -status => 301
         );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a perl script which calls another perl script using backticks. I want
I have a Perl/POE/Tk script running on Win32 ActivePerl that calls executables using system
I have a perl script that uses the CGI::Session::Drive::memcached, but I want to be
I have a Perl script that I'm attempting to set up using Perl Threads
I have a Perl script where I maintain a very simple cache using a
I have a Perl script that I'd like to run on Windows, using either
I have a simple Perl script which runs as a Linux daemon using an
Using perl 5.8.8 on windows server I am writing a perl cgi script using
I have a script that's written in perl, and executed as CGI. It works
I'm using Eclipse EPIC IDE to write some Perl CGI scripts which call some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.