Rodrigo Tavares wrote:
Hello,

Hello,

I got make a script, see below :

#!/usr/bin/perl

 use strict;
 use warnings;

 print "Enter 5 digits: ";
 my $digit = <STDIN>;

 my $cont = length($digit) - 1;
 if ($cont > 5)
  {
    print "Only five digits ! \n"
  }
 else
  {
   my @arrow = split(//, $digit);
   print "$arrow[0]\n";
   print "$arrow[1],$arrow[1]\n";
   print "$arrow[2],$arrow[2],$arrow[2]\n";
   print "$arrow[3],$arrow[3],$arrow[3],$arrow[3]\n";
   print
"$arrow[4],$arrow[4],$arrow[4],$arrow[4],$arrow[4]\n";
  }

Or more simply as:

#!/usr/bin/perl

use strict;
use warnings;

print 'Enter 5 digits: ';
( my @arrow = <STDIN> =~ /\d/g ) == 5 or die "Only five digits !\n";

for ( 0 .. $#arrow ) {
    print join( ',', ( $arrow[ $_ ] ) x ( $_ + 1 ) ), "\n";
    }

__END__



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

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


Reply via email to