The problem of repeating all those pushes is not necessary. A nice data structure like a hash will settle that:
The %listdb hash automatically has as many keys as your files have initial characters. Those keys are created as needed by uppercasing the first character of the name, which is extracted by substr. By treating the hash value as an array reference, it automagically becomes one, giving you a hash of arrays - affectionately known as HoA.sub read_db_list { my %listdb; # ... in the read loop # replacing the if block push @{$listdb{ uc substr( $file_name, 0, 1) }}, $infoline; # after all is read return \%listdb; }
To print all that you may want to look at one of the template modules, or else use CGI.pm's handy html generation functions. Those are very nifty with array references.
After Compline,
Zaxo
In reply to Re: Help to improving my code please?
by Zaxo
in thread Help to improving my code please?
by spacey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |