s#(<img[^>]+src\s*=\s*(?:"|'))/img#$1/foo#s
[download]

Perl6 sample code...

Simple stab:

#!/home/clive/rakudo-star/bin/perl6 my $number = 100.rand.ceiling; say "I'm thinking of a number between 1 and 100 inclusive. What is it? +"; for ^7 { my $guess = +prompt("Enter your guess:"); given $guess { when ! *.isa(Int) { say "Hey, that's not an integer!" } when * > $number { say "Too high!" } when * < $number { say "Too low!" } default { say "You got it!!!"; exit } } } say "Really? I was thinking of $number";
[download]

Class version (note, unfinished - allows infinite guesses)

#!/home/clive/rakudo-star/bin/perl6 class GuessNumGame { has $number = 100.rand.ceiling; has $guess-count = 0; has $.running is rw = True; method guess ($guess) { given $guess { when ! *.isa(Int) { say "Hey, that's not an integer!" } when * > $number { say "Too high!" } when * < $number { say "Too low!" } default { say "You got it!!!"; $.running=False } } } } my $game = GuessNumGame.new; say "I'm thinking of a number between 1 and 100 inclusive. What is it? +"; while $game.running { $game.guess( +prompt("Enter your guess:") ); }
[download]