View Single Post
  #6   (View Single Post)  
Old 24th October 2016
PapaParrot's Avatar
PapaParrot PapaParrot is offline
parrot
 
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 472
Default

With some help from "perl monks",
I made this, for my grandaughter to practice her
first multiplication tables
a-multiplication.pl
Code:
#!/usr/bin/perl
#use strict;
#use warnings;

print "Por favor escribe tu nuombre:\n";
$name = <>;
chomp($name);
print "Hola!, ", $name, "!\n";
print " $name, Vamos a hacer tablas ,tecla algunas letras o numeros:\n";
$string = <>;
chomp($string);
print "Lo que teclado,tiene:\n",length($string),"  letras o numeros\n";
$_= <STDIN>;
print "[Instrucciones, ctrl-c o \"quit\" para salir]\n";
print "Entra para continuar\n";
$_ = <STDIN>;
OUTER: {print "\033[2J";
    my ($x, $y) = map { int rand $_ } qw/11 11/;
    INNER: {
        print "$x x $y = ";
        local $_ = <STDIN>;
        chomp;
        last OUTER if m/^quit$/;
        redo INNER unless m/^\d+$/;
        if ($_ == ($x*$y))
  { print "Muy buen es correcto!\n"; redo OUTER }
        else
          { print "Oops!No es correcto,haga otra vez\n"; redo INNER }

    }
}
Reply With Quote