in reply to .cgi?action params
Please read I know what I mean. Why don't you?
Then read Short, Self-Contained, Correct Example.
That said, if you retrieve xxx.cgi?action=one&reaction=two, the following
#!/usr/bin/perl use CGI; my $query = CGI->new; my $action = $query->param('action'); my $reaction = $query->param('reaction'); print $query->header, $query->start_html, "<h1>Result</h1>\n", "Action: ", $action || "no action", "<br>", "Reaction: ", $reaction || "no reaction", $query->end_html;
will - if the webserver is correctly configured, if xxx.cgi has the correct permissions etc - serve a page reading:
Result
Action: one
Reaction: two
Now let me comment the snippets you posted.
my GetLink = 'one&reaction=two'; query string xxx.cgi?action=' + GetLink;
doesn't compile. Running that yields:
No such class GetLink at - line 1, near "my GetLink" syntax error at - line 1, near "my GetLink =" Can't find string terminator "'" anywhere before EOF at - line 2.
Then,
my $query = new CGI; my $action = lc ($query->param('action')); ....... elsif ($action eq "one"){ my ($string1, $string1 ) = @_; my ($string2, $string2 ) = @_; warn("string2 = '$string2'");
declaring a variable twice as in my ($string1,$string1) makes no sense at all. The special array @_ should only be used inside a subroutine and contains its arguments, if any. See perlvar and perlsub. Actually, don't see, read those pages.
Lastly,
elsif ($action eq "one"){ my $query = CGI->new(); my $string2 = $query->param('reaction'); warn("string2 = '$string2'");
here you are masking the outer $query with a new CGI object inside the elsif block. Why?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: .cgi?action params
by tultalk (Monk) on May 28, 2017 at 15:44 UTC | |
by marto (Cardinal) on May 29, 2017 at 07:58 UTC | |
by marinersk (Priest) on May 29, 2017 at 12:03 UTC |