Richard Kofler wrote:
My sub does, what I expect it to do, but somehow it does look
clumpsy to me, when compared to code from the knowing ones
in c.l.p.m  :)

Not sure why you say that. To me, it seems to be an appropriate approach.

I'd apreciate it very much, if someone could hint me into
better ways to do it.

You can use the $. variable instead of the separate $icnt counter (provided that you accept that possible blank lines get included...).


You may want to remove the field names from the database, to avoid the need to test for them at each iteration.

You can use the return value from the split() operation instead of testing the length of respective line.

chomp()ing is redundant when you use split() that way.

So, this is a shorter version of the function:

    sub tabinfo_hash {
        my @elems = qw/ extents nptot npused npdata nrows rsize /;
        my %tih;
        while (<DATA>) {
            ( my $table, my @vals) = split or next;
            @{ $tih{$table} }{ @elems } = @vals;
            last if $. > 10;
        }
        \%tih;
    }

And there is one main question left:
Is HoH appropriate for what I do, or is HoA a better way to go.

A HoH allows for clearer code IMO.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




Reply via email to