Rodrigo Tavares schreef:

> Write a program than user type five digits,
> separates the individual digits of number, and print
> the five digits time five, the four digit four times,
> thus for ahead.

#!/usr/bin/perl
  use strict;
  use warnings;

  my $n = 5;           # number-of-digits
  print "Enter $n digits: ";

  my $input = <>;      # read from STDIN
  $input =~ s/\D+//g;  # remove non-digits

  length( $input ) == $n
      or die ":-(  I said $n digits!\n";

  for my $i ( reverse 1 .. $n ) {
    print substr( $input, $i - 1, 1 ) x $i, "\n";
  }

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to