Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Perl Purity Test (For Update)

by nferraz (Monk)
on Mar 31, 2006 at 12:27 UTC ( [id://540438]=note: print w/replies, xml ) Need Help??


in reply to Perl Purity Test (For Update)

I wrote this script to play the above purity test:

#!/usr/bin/perl -w use strict; use Term::ReadKey; my %answer; while(<DATA>) { if (/^\.\.\./) { chomp; print "$_ (y/n)"; my $ans = ''; ReadMode('cbreak'); $ans = ReadKey(0) while ($ans ne 'y' and $ans ne 'n'); print "$ans\n"; ReadMode('normal'); $answer{$ans}++; $answer{t}++; } else { print; } } my $py = $answer{y} / $answer{t} * 100; my $pn = $answer{n} / $answer{t} * 100; print <<"EOF"; Results: You answered: $answer{y} 'yes' ($py %) $answer{n} 'no' ($pn %) EOF __DATA__

(Copy and paste the purity test after __DATA__)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 00:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found