Re: A simple program

2007-08-06 Thread Dr.Ruud
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

Re: A simple program

2007-07-31 Thread Chas Owens
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

Re: A simple program

2007-07-31 Thread Jeff Pang
--- 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"

Re: A simple program

2007-07-31 Thread Chas Owens
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(),

Re: A simple program

2007-07-31 Thread Chas Owens
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

Re: A simple program

2007-07-31 Thread Rodrigo Tavares
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: > >>

Re: A simple program

2007-07-31 Thread Chas Owens
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

Re: A simple program

2007-07-31 Thread Rodrigo Tavares
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 > >

Re: A simple program

2007-07-31 Thread John W. Krahn
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 ( $

Re: A simple program

2007-07-31 Thread Chas Owens
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"; >

Re: A simple program

2007-07-31 Thread Chas Owens
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 ( $_

Re: A simple program

2007-07-31 Thread John W. Krahn
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);

Re: A simple program

2007-07-31 Thread Rodrigo Tavares
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 "

Re: A simple program

2007-07-28 Thread Rodrigo Tavares
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

Re: A simple program

2007-07-27 Thread John W. Krahn
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

Re: A simple program

2007-07-27 Thread Rodrick Brown
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

A simple program

2007-07-27 Thread Rodrigo Tavares
Hello, How I can to make this program, where the variable is enter though , how separete the digits ? 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. Best regards,