Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Multiple params

by htmanning (Friar)
on Jan 20, 2018 at 20:05 UTC ( [id://1207592]=perlquestion: print w/replies, xml ) Need Help??

htmanning has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I'm missing something here. I have a link with 2 params, (cell and target_dir).

use CGI qw(:standard); use CGI 'param'; $store = new CGI; $cell = $store->param('cell'); $target_dir = $store->param('target_dir');

The link looks like this: http://domain.com/script.pl?cell=123&target_dir=/usr/me/attachments/

All I get from the script is the target_dir. I'm not getting the cell returned. What am I doing wrong?

Replies are listed 'Best First'.
Re: Multiple params
by hippo (Bishop) on Jan 21, 2018 at 17:58 UTC
    What am I doing wrong?

    You are not showing the full script. See SSCCE.

    Here's one showing how it works:

    $ cat show.cgi #!/usr/bin/perl use strict; use warnings; use CGI; my $store = CGI->new; my $cell = $store->param ('cell'); my $td = $store->param ('target_dir'); print $store->header (-type => 'text/plain'), "Cell is $cell and Target Dir is $td\n"; $ ./show.cgi cell=1234 target_dir=/foo Content-Type: text/plain; charset=ISO-8859-1 Cell is 1234 and Target Dir is /foo
Re: Multiple params
by choroba (Cardinal) on Jan 20, 2018 at 22:29 UTC
    It should work. It works for me (but I'm running CGI through PSGI with CGI::Emulate::PSGI).

    BTW, why do you import the param subroutine? With the object interface of CGI, you don't need to import any subroutines.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: Multiple params (sub DebugCGI101
by Anonymous Monk on Jan 20, 2018 at 23:49 UTC

    Like choroba says it should work, but,

    What webserver are you using (mapache moo.A.1245?? ) What CGI.pm are you using?

    Hehehe, CGI.pm, never ceases to confuse :) delete this stuff from your program

    ### use CGI qw(:standard); ## REMOVE MYSTERY CODE ### use CGI 'param'; ## REMOVE MYSTERY CODE

    Then try this program in your browser and see what you get

    #!/usr/bin/perl -- use strict; use warnings; use CGI; my $store = CGI->new; my $cell = $store->param('cell'); my $target_dir = $store->param('target_dir'); print $store->header; print $store->escapeHTML( $cell ); print '<hr>'; print $store->escapeHTML( $target_dir ); print '<hr>'; DebugCGI( $store); exit 0; sub DebugCGI { my( $cgi ) = @_; $cgi ||= CGI->new; binmode STDOUT, ':encoding(UTF-8)'; $cgi->charset( 'UTF-8' ); print $cgi->header( -charset => 'UTF-8' ); print $cgi->start_html, $cgi->b( rand time, ' ', scalar gmtime ), '<table border="1" width="%100"><tr><td>', $cgi->Dump, '</td>', '<td><div style="white-space: pre-wrap; overflow: scroll;">', $cgi->escapeHTML( DD( $cgi ) ), '</div></td></tr></table>', CGI->new( \%ENV )->Dump, $cgi->end_html; } ## end sub DebugCGI sub DD { require Data::Dumper; return scalar Data::Dumper->new( \@_ )->Indent( 1 )->Useqq( 1 )->D +ump; } ## end sub DD __END__

    Take special note of the value of QUERY_STRING

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1207592]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-23 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found