I'm looking for some code that does the same sort of formatting done by the Unix 'ls' command, which looks something like this:
B Digest Filter MIME SDBM_File Time util ByteLoader DynaLoader GDBM_File NDBM_File Safe Unicode Cwd Encode I18N ODBM_File Socket XS DB_File Errno IO Opcode Storable attrs Data Fcntl IPC POSIX Sys re Devel File List PerlIO Thread threads
The salient features are a) to read entries in sorted order you read down one column before moving over to the next; b) columns are left-justified; c) columns are as wide as they need to be to fit the largest entry within them; d) as many columns as possible are used; e) all but the last column have the same number of entries, and the last column has no more than the other columns.
This is intended for the list of available commands in a help system roughly modelled on gdb's. I haven't written any code to do this yet, because I imagine someone has already done so.
I did find one implementation (thanks ysth) in the implementataion of ls in the Perl Power Tools project, but that uses a more simplistic approach that makes all columns as wide as the widest column, rather than making each column only as wide as it needs to be.
Any suggestions gratefully received.
Hugo
In reply to 'ls -C' column style by hv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |