I am on v5.8.5 / cygwin or v5.8.1 when on Linux or Solaris. I wrote a small sub to process output from a database utility giving metainformation one line per table/index.
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 :) I'd apreciate it very much, if someone could hint me into better ways to do it. And there is one main question left: Is HoH appropriate for what I do, or is HoA a better way to go. After all I use this sub very much like a lookup table, much like in the main:: of the code further down Here is what I've got so far (pasted after successful test) #!/usr/bin/perl use warnings; use strict; use diagnostics; # testscript showing use of hoh # RK 20041109 V01 initial version sub tabinfo_hash { # t_info file into hash tih # # Input # # table extents nptot npused npdata nrows rsize # table1 5 1671035 1653542 1653131 39668306 78 my @elems = qw/ extents nptot npused npdata nrows rsize /; my %tih; my $icnt = 0; while (<DATA>) { ##xmpl: my @players = qw/ barney fred dino /; ##xmpl: my @bowling_scores = (195, 205, 30); ##xmpl: @score{ @players } = @bowling_scores; chomp; next if (length == 0); next if ( /nptot\s+npused/ ); ( my $table, my @vals) = split; @{ $tih{$table} }{ @elems } = @vals; $icnt++; last if ($icnt > 10); } return \%tih; } my $ref_tih = tabinfo_hash; print "table01/npdata: $ref_tih->{table01}{npdata}\n"; print "table02/npused: $ref_tih->{table02}{npused}\n"; __DATA__ table extents nptot npused npdata nrows rsize table01 5 1671035 1653542 1653131 39668306 78 table02 22 12520365 12513173 12509883 12509883 1968 table03 10 112745 112680 0 0 1968 table04 1 467507 465955 0 0 277 table05 4 338890 338581 0 0 114 table06 1 223580 223293 0 0 108 table07 2 1179499 1120234 1119956 12318902 168 table08 1 512 122 121 2401 95 table09 1 68 21 0 0 95 table10 1 65512 35431 35422 212530 295 table11 2 81892 80881 80860 2424742 62 table12 1 5017 4915 0 0 376 index01 1 48308 48068 0 0 304 index02 2 8432 8397 0 0 376 table13 1 65512 10162 4958 4958 1983 table14 1 262098 58452 15572 15576 2592 table15 1 131041 97083 97058 5920431 29 index03 1 197 5 0 0 305 index04 1 4442 4386 0 0 27 index05 1 1318 973 0 0 149 __END__ Resulting output is: $ ./process_tabinfo_V01_dos.pl table01/npdata: 1653131 table02/npused: 12513173 Thank you for any help dic_k -- Richard Kofler SOLID STATE EDV Dienstleistungen GmbH Vienna/Austria/Europe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>