CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Retrieving Info

 



Pro_4
User

May 1, 2001, 1:36 PM

Post #1 of 9 (2284 views)
Retrieving Info Can't Post

I am sure there are many ways to retrieve info from a form and assign that to scalars. The only way i know of is doing
$blah = param('something');

But unfortunately something must be wrong with the way i typed it in because it wont work. Anyways are there any better ways to do this and what is the fastest solution ( if applicable ).

Thanks :)

People Engrossed by a Reliable Language


Jasmine
Administrator / Moderator

May 1, 2001, 1:50 PM

Post #2 of 9 (2282 views)
Re: Retrieving Info [In reply to] Can't Post

If you're using $blah = param('something'), make sure that you have the following line at the top of your script:


Code
use CGI qw/:standard/;

If that's not it, could you please explain a little more? :) Are you getting an error? Have you confirmed that field "something" is being passed to the script?



Pro_4
User

May 1, 2001, 1:53 PM

Post #3 of 9 (2282 views)
Re: Retrieving Info [In reply to] Can't Post

The reason why i asked this question was because of this script i am working on:

Code
#!/usr/bin/perl -w 
# rating.cgi used to calculate zone ratings.
# this is the initial rating info and calculate the points
$r1 = param->("r1");
$r2 = param->("r2");
$pw = param->("pw");
$pl = param->("pl");
$game = param->("game");
$f = (( $r2 - $r1 ) /400 );
if ( $f > 1) { $f = 1 } else { $f = $f };
if ( $f < -1) { $f = -1 } else { $f = $f };
# this narrows it down to did you win or lose
if ( $game eq "lose" ) { $lose = (16 *(-1 + $f)) } else { $win = (16 *(1 + $f)) };
if ( $win < 1) { $win = 1 } else { $win = $win};
if ( $lose > -1) { $lose = -1 } else { $lose = $lose};
# finally we are down to figuring out the new rating
if ( $game eq "lose" ) { $new = $r1 +( $lose / $pl ) } else { $new = $r1 +( $win / $pw ) };
print "Your new rating is $new\. \n If you want to find out how much your incompletes are
worth play five games recording the number this script gives you every time: $lose \n If you
won you will have a blank, calculate that as 0.";

Thanks, also i would appreciate it if you would debug the script ( i think i worked all the kinks out tho).

:)


People Engrossed by a Reliable Language


(This post was edited by Jasmine on May 1, 2001, 4:39 PM)


Pro_4
User

May 1, 2001, 1:56 PM

Post #4 of 9 (2282 views)
Re: Retrieving Info [In reply to] Can't Post

hehe you posted while i was revising my new post.

Let me try that in my script and how do i confirm that it is being passed?

People Engrossed by a Reliable Language


(This post was edited by Pro_4 on May 1, 2001, 1:21 PM)


Jasmine
Administrator / Moderator

May 1, 2001, 5:41 PM

Post #5 of 9 (2275 views)
Re: Retrieving Info [In reply to] Can't Post

I'm not 100% what you're asking... if you're assigning a variable from a piece of input, you just print the variable...


Code
use CGI qw/:standard/; 

$something = param('something');

print $something;

If I've misunderstood, please let me know.

I hope you don't mind, but I edited your post just so the sideways scroll wasn't as phenomenal as it turned out to be. I didn't change anything else.



Pro_4
User

May 2, 2001, 11:10 AM

Post #6 of 9 (2259 views)
Re: Retrieving Info [In reply to] Can't Post

thanks you answered my question.

People Engrossed by a Reliable Language


Pro_4
User

May 3, 2001, 10:30 AM

Post #7 of 9 (2254 views)
Re: Retrieving Info [In reply to] Can't Post

Yes i finally got a script to work online! Check it out at http://etow.virtualave.net/rating.html ( it isnt to pretty looking but it works :) )

:) Thanks for the help

People Engrossed by a Reliable Language


Pro_4
User

May 3, 2001, 10:39 AM

Post #8 of 9 (2254 views)
Re: Retrieving Info [In reply to] Can't Post

BTW do you have to put "" around print "$variable"; I saw you didnt put it around your print $variable; so i wasnt sure if that was a typo or can you actually do it.
Thanks :)

People Engrossed by a Reliable Language


Jasmine
Administrator / Moderator

May 3, 2001, 11:24 AM

Post #9 of 9 (2253 views)
Re: Retrieving Info [In reply to] Can't Post


Code
my $variable = 'whatever'; 

print $whatever; #perfectly legal; prints whatever

Quotes are necessary for bare text, and any variable inside double quotes will be interpolated, meaning that its value will be inserted.


Code
print "$variable and whoever"; #prints whatever and whoever

You may be interested in japhy's Quoting Operators and Interpolation article in the Learning Center.



(This post was edited by Jasmine on May 3, 2001, 10:35 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives