Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Writing a perl quiz. Need advice.

by zengargoyle (Deacon)
on Mar 08, 2003 at 05:55 UTC ( [id://241344]=note: print w/replies, xml ) Need Help??


in reply to Writing a perl quiz. Need advice.

one thing, you're not lazy enough.

# untested use strict; my %questions = ( 1 => { question => "Who's Perl's top dog?", answer => "Larry Wall" }, 2 => { question => "What's the answer?", answer => "42" }, ); foreach my $question (sort {$a <=> $b} keys %questions) { my $guess = param("$Q$question"); print "$question). You answered: $questions{$question}{question} wit +h $guess. "; if ($guess eq $questions{$question}{answer}) { print q|<font color="green">Correct</font><br>|; } else { print q|<font color="red">Incorrect</font><br>|; } } # keeping totals left as homework =)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-23 14:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found