Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Use 'param' in if statement.

by krachen (Novice)
on Dec 07, 2004 at 22:00 UTC ( [id://413019]=perlquestion: print w/replies, xml ) Need Help??

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

In a script, I am executing a browser page with two options. One to select data and another to update data. I'm using-
print "<td><a href=\"first.pl?item=select\">Select Info</a></td>"; print "<td><a href=\"first.pl?item=update\">Update Info</a></td>";
I then use an IF statement to choose:
if (param("item") eq "select") { &retrieve_data; } elsif (param("item") eq "update") { &update_data; } sub retrieve_data {
But when I click either option, it stops at the 'param' statement. I use this all the time on one server my own. the server at work is the same version of redhat and I think the install should be the same for both except for the Oracle stuff on the one at work. If I take the ref to param out, I can execute the rest of the script. Any ideas???
Krachen

Edit by tye: Use CODE tags

Replies are listed 'Best First'.
Re: Use 'param' in if statement.
by bradcathey (Prior) on Dec 08, 2004 at 01:12 UTC

    To expand on injunjoel's reply, try:

    use CGI; my $query = new CGI; if ($query->param("item") eq "select") { &retrieve_data; } elsif ($query->param("item") eq "update") { &update_data; } sub retrieve_data {

    That should do it. It's one of those crazy bugs that we have all stared at for hours and simply not seen the obvious. Take heart, we've all been there.


    —Brad
    "Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton
Re: Use 'param' in if statement.
by injunjoel (Priest) on Dec 07, 2004 at 23:03 UTC
    Greetings all,
    How are you using CGI?
    Are you creating a CGI object?
    Are you using use CGI qw(:standard);?
    Have you checked if there is a version difference in the CGI.pm between the box that doesn't work and the one that does?

    -InjunJoel
    "I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo
Re: Use 'param' in if statement.
by eric256 (Parson) on Dec 07, 2004 at 22:31 UTC

    A better definition of "it stops" would help. Do you get an error? Did you check your webservers error log?


    ___________
    Eric Hodges
Re: Use 'param' in if statement. (Excuse my hastiness)
by krachen (Novice) on Dec 09, 2004 at 19:58 UTC
    I am the one that posted "Use 'param' in if statement. by krachen.". I am a newbie to this forum and to perl. I am a veteran programmer who is now fighting to aquire the knowledge of premier languages. I have mastered languages from Cobol and Assembler through many forms of SQL and unix scripting and allot in between (15+ years). Please excuse my hastiness in my posts. I have allot to learn in a short amount of time. Thank you for your time and expertise. "My life is my '67 Dodge and my Greyhounds, fast friends"
    Krachen

    2004-12-09 Edited by Arunbear

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-20 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found