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";
  }


Best regards,

Rodrigo Faria

--- "John W. Krahn" <[EMAIL PROTECTED]> escreveu:

> Rodrick Brown wrote:
> > On 7/27/07, Rodrigo Tavares
> <[EMAIL PROTECTED]> wrote:
> >>
> >> How I can to make this program, where the
> variable is
> >> enter though <STDIN>, how separete the digits ?
> >>
> > use split
> > 
> >> Exercice
> >> 01)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 -w
> > use strict;
> > use warnings;
> > 
> > print "Enter a digit: ";
> > my $digit = int(<STDIN>);
> > print map { next unless $_ =~ /^\d+$/; $_ *
> $_,"\n" } split//,$digit;
> 
> perldoc -f next
>      next LABEL
>      next    The "next" command is like the
> "continue" statement in C; it
>              starts the next iteration of the loop:
> 
>                  LINE: while (<STDIN>) {
>                      next LINE if /^#/;      #
> discard comments
>                      #...
>                  }
> 
>              Note that if there were a "continue"
> block on the above, it would
>              get executed even on discarded lines. 
> If the LABEL is omitted,
>              the command refers to the innermost
> enclosing loop.
> 
>              "next" cannot be used to exit a block
> which returns a value such
>             
>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>              as "eval {}", "sub {}" or "do {}", and
> should not be used to exit
>             
>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>              a grep() or map() operation.
>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> 
> 
> 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/
> 
> 
> 



      Alertas do Yahoo! Mail em seu celular. Saiba mais em 
http://br.mobile.yahoo.com/mailalertas/

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


Reply via email to