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/


Reply via email to