0

I want to know how to pass input parameter to perl cgi . I have a flex application, it will take name and some other details of a person, then i want to call a perl cgi with these details as input. How it's possible? Is appending parameter at the end of url eg:http://localhost/cgi-bin/test.pl?name=abc&location=adsas ,the only method to pass parameter to perl cgi?

How can i get passed parameter inside perl cgi?

I have tried this code but didn't get output

use CGI qw(:standard);
use strict;
my $query = new CGI;
my $name = $query->param('name');
my $loc = $query->param('loc');
print "$name is from $loc\n"; 
smartmeta
  • 1,149
  • 1
  • 17
  • 38
neha88
  • 79
  • 5

1 Answers1

1

The client (Flex) is irrelevant. A query string is a query string and post data is post data, no matter what sends it to the server.

If you are using Dancer, then you are using Plack. If CGI is involved, then Plack will take care of it and translate all the environment variables to the standard Plack interface which Dancer will consume.

You can't access the CGI environment variables directly (and nor can CGI.pm).

From the docs:

get '/foo' => sub {
    request->params; # request, params parsed as a hash ref
    request->body; # returns the request body, unparsed
    request->path; # the path requested by the client
    # ...
};

Therefore:

my $params = request->params;
my $name = $params->{'name'};
my $loc = $params->{'loc'};
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335