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 = <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
>         or die "Only five digits !\n";
> my $i = 1;
> print map { $_ x $i++, "\n" } @a;
>

oops, the map should be

print map { join(",", ($_) x $i++),"\n" } @a;

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


Reply via email to