"John W. Krahn" <[email protected]> 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: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/