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: > >> > >> #!/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__ > > snip > > > > Two issues: > > this doesn't fail on "foo1bar2baz345" > > it does fail on "1234" (the original doesn't) > > > > I was thinking > > > > #!/usr/bin/perl > > > > use strict; > > use warnings; > > > > print 'Enter 5 digits: '; > > my @a = <STDIN> =~ /^(\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 option it > would still only contain one > line because the readline is in scalar context so > the /g option would still be > superfluous. :-) > > > > or die "Only five digits !\n"; > > my $i = 1; > > print map { $_ x $i++, "\n" } @a; > > > 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/