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