#  test du passage de paramètre

if ($#ARGV == -1) {
   print stderr "\n syntaxe : tabmult nombre_entier_positif\n\n" ;
   exit(-1) ;
} ; # fin de si

# affectation du paramètre

$nbChoisi = $ARGV[0] ;

# relance éventuelle

while (( not entier( $nbChoisi )) ) {
    print " nombre incorrect. Redonner un nombre ENTIER "."\n" ;
    chomp($nbChoisi=<STDIN>) ;
} ; # nombre invalide


# boucle d'affichage

print " Table de " ." ". $nbChoisi."\n" ;
for ( $indb = 1  ;  $indb <= 10  ; $indb++ ) {
    $produit = $nbChoisi * $indb  ;
    $find = &format( $indb , 2 , 0 )  ;
    $fpro = &format( $produit , 5 , 0 )  ;
    print $find ." ". " fois " ." ". $nbChoisi ." ". " = " ." ". $fpro."\n" ;
} ; # indb de1a 10

##### sous-programmes :

sub  entier  {
  # renvoie "vrai" si le paramètre est un entier éventuellement signé
  my $parm_entier = $_[0] ;
  return $parm_entier =~ /^[+-]?\d+$/ ;
} ; # fin sub entier

sub  format  {
  # formate un nombre (syntaxe plus simple que sprintf)
  return( sprintf("%$_[1]d",$_[0]) ) ;
} ; # fin sub format

