Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^3: Guess Number

by GrandFather (Saint)
on Sep 01, 2006 at 22:03 UTC ( [id://570843]=note: print w/replies, xml ) Need Help??

in reply to Re^2: Guess Number
in thread Guess Number

I considered do {} while, but that required declaring the variables outside the loop and, besides, I felt there was some virtue in showing OP the bare block trick.

Using the comma operator:

use strict; use warnings; 1 while (print "Guess the Code: "), <> != (1+int rand 10); print "\n Time taken to break the Code ..: ", time()-$^T, " seconds\n +";

gets the prompt printed for each iteration.

Using $^T is nice btw. Something I'd not have thought of - I'm still learning. :)

DWIM is Perl's answer to Gödel

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-20 05:01 GMT
Find Nodes?
    Voting Booth?

    No recent polls found