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
On 7/31/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
>
> --- Chas Owens <[EMAIL PROTECTED]> wrote:
> >
> > oops, the map should be
> >
> > print map { join(",", ($_) x $i++),"\n" } @a;
> >
>
> Also using for loop is may better since many ppl on
> this list said map would consume too much memory if
> th
--- Chas Owens <[EMAIL PROTECTED]> wrote:
>
> oops, the map should be
>
> print map { join(",", ($_) x $i++),"\n" } @a;
>
Also using for loop is may better since many ppl on
this list said map would consume too much memory if
the input array is large enough.
print join(",", ($_) x ++$i),"\n"
On 7/31/07, Chas Owens <[EMAIL PROTECTED]> wrote:
snip
> print join(",", ($arrow[2]) x 3), "\n";
>
> which is the same as
>
> print join(",", $arrow[2], $arrow[2], $arrow[2]), "\n";
snip
It is important to note that
print join(",", (time()) x 3), "\n";
is not the same as
print join(",", time(),
On 7/31/07, Rodrigo Tavares <[EMAIL PROTECTED]> wrote:
> Hello John,
>
> You could explain the below line ?
>
> print join( ',', ( $arrow[ $_ ] ) x ( $_ + 1 ) ),
> "\n";
snip
x is the repetition operator.
When the left side is a scalar it builds a string that contains the
left side repeated the
Hello John,
You could explain the below line ?
print join( ',', ( $arrow[ $_ ] ) x ( $_ + 1 ) ),
"\n";
Thanks,
Rodrigo Faria
--- "John W. Krahn" <[EMAIL PROTECTED]> escreveu:
> Chas Owens wrote:
> > On 7/31/07, John W. Krahn <[EMAIL PROTECTED]>
> wrote:
> > snip
> >> Or more simply as:
> >>
On 7/31/07, John W. Krahn <[EMAIL PROTECTED]> wrote:
snip
> > my @a = =~ /^(\d)(\d)?(\d)?(\d)?(\d)?$/g
>
> You are using the /g option but the pattern is anchored at the beginning and
> ending of the line so it will only match once making the /g option
> superfluous. (Even if you added the /m opt
Hello John,
I don't understood the line in loop for the # in
variable arrow.
How It can to be used ?
Best regards,
Rodrigo
--- "John W. Krahn" <[EMAIL PROTECTED]> escreveu:
> Rodrigo Tavares wrote:
> > Hello,
>
> Hello,
>
> > I got make a script, see below :
> >
> > #!/usr/bin/perl
> >
Chas Owens wrote:
On 7/31/07, John W. Krahn <[EMAIL PROTECTED]> wrote:
snip
Or more simply as:
#!/usr/bin/perl
use strict;
use warnings;
print 'Enter 5 digits: ';
( my @arrow = =~ /\d/g ) == 5 or die "Only five digits !\n";
for ( 0 .. $#arrow ) {
print join( ',', ( $arrow[ $_ ] ) x ( $
On 7/31/07, Chas Owens <[EMAIL PROTECTED]> wrote:
> On 7/31/07, John W. Krahn <[EMAIL PROTECTED]> wrote:
> snip
> > Or more simply as:
> >
> > #!/usr/bin/perl
> >
> > use strict;
> > use warnings;
> >
> > print 'Enter 5 digits: ';
> > ( my @arrow = =~ /\d/g ) == 5 or die "Only five digits !\n";
>
On 7/31/07, John W. Krahn <[EMAIL PROTECTED]> wrote:
snip
> Or more simply as:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> print 'Enter 5 digits: ';
> ( my @arrow = =~ /\d/g ) == 5 or die "Only five digits !\n";
>
> for ( 0 .. $#arrow ) {
> print join( ',', ( $arrow[ $_ ] ) x ( $_
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 = ;
my $cont = length($digit) - 1;
if ($cont > 5)
{
print "Only five digits ! \n"
}
else
{
my @arrow = split(//, $digit);
Hello,
I got make a script, see below :
#!/usr/bin/perl
use strict;
use warnings;
print "Enter 5 digits: ";
my $digit = ;
my $cont = length($digit) - 1;
if ($cont > 5)
{
print "Only five digits ! \n"
}
else
{
my @arrow = split(//, $digit);
print "$arrow[0]\n";
print "
Hello,
In my first lesson, not extist split.
And without split ?
There is a mode more simple ?
Best regards,
Rodrigo Faria
--- Rodrick Brown <[EMAIL PROTECTED]> escreveu:
> On 7/27/07, Rodrigo Tavares
> <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > How I can to make this program, where the
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 , how separete the digits ?
use split
Exercice
01)Write a program than user type five digits,
separates the individual digits of number, and print
t
On 7/27/07, Rodrigo Tavares <[EMAIL PROTECTED]> wrote:
> Hello,
>
> How I can to make this program, where the variable is
> enter though , how separete the digits ?
>
use split
>
> Exercice
> 01)Write a program than user type five digits,
> separates the individual digits of number, and print
> th
16 matches
Mail list logo