develooper Front page | perl.beginners | Postings from February 2002

RE: Hash Question

Thread Previous | Thread Next
Chas Owens
February 7, 2002 14:19
RE: Hash Question
Message ID:
On Thu, 2002-02-07 at 14:27, Balint, Jess wrote:
> After hours of pondering and sitting in wonder of simple it is, I have come
> up with something. I do believe that this:
>         for my $i (0..$#keys) {
> Quite possibly should be
> 	foreach ( @keys ) {
> Otherwise, why would you have
> my @keys = (0, 1, 2, 3);
> Instead of just $keys = 3 and then 0..$keys. If there is any wrong in this
> thinking, please lemme know. Thank you.
> -Jess
<snip />

Bugger me.  This is what I get for just rattling off code and testing it
for superficial correctness.  It was originally $fields[$keys[$i]] as I
was using $i for debug purposes.  Then I scrapped that design, but kept
the bulk of the code around since some of it was useful, and this stayed
when I should have change the loop to 

foreach my $i ( @keys ) {

That's twice today I feel like an idiot.  Also the "#eval method, ugly"
comment is not supposed to be there.  It too is a relic of the original
hack to get it working (which got discarded as being far, far to ugly). 

Today is Pungenday the 38th day of Chaos in the YOLD 3168
Or is it?

Missle Address: 33:48:3.521N  84:23:34.786W

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About