Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Looking for pointers or optimizations.

by tobyink (Abbot)
on Aug 21, 2012 at 13:55 UTC ( #988739=note: print w/ replies, xml ) Need Help??


in reply to Looking for pointers or optimizations.

#!/usr/bin/env perl use 5.010; use strict; use constant LIMIT => 8; my $word = uc "hello"; my $wrong = 0; my $already = ''; my $displayed; while ($wrong < LIMIT) { $displayed = join '', map { m{ ^ [ $already ] $ }x ? $_ : '*' } split '', $word; if ($displayed eq $word) { say "Yeah, baby, yeah!"; exit(0); } say "Word: $displayed", say "Wrong guesses: $wrong"; print "Please guess a letter... "; chomp(my $guess = <>); $already .= ($guess = quotemeta uc $guess); $wrong++ unless $word =~ m{ $guess }x; } die("Dude, it was '$word'\n");
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: Looking for pointers or optimizations.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-12-25 00:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls