"John W. Krahn" <jwkr...@shaw.ca> writes:

> Much simpler as:
>
> for ( my $i = 0; $i <= $#ar1; $i += 3 ) {
>     dispt( $r1name, @ar1[ $i .. $i + 2 ] );
>     }

[...]

Man, that is a heck of a lot tidier.  I was completely unfamiliar with
that way of getting at parts of an array (though now I remember seeing
some examples like that in `Learning perl)'.  And not clever enough to
figure out how to associate numbers to the names like that. (just
using simple math I mean)

I'm curious about one thing I see there:

 `/\A\d+\z/ ' as opposed to `/^\d+$/'

in this snippet:

        if ( $chosen =~ /\A\d+\z/ && $chosen >= 1 && $chosen <= @h ) {
            print "Taking some action on $h[$chosen - 1]\n";
            last;
            }
         [...]

Is the second formulation (`/^\d+$/' - the one I used) likely to miss under
certain conditions?


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to