SPUG: Pretty-Printing Nested Hashes?

Joshua Lanza jlanza at gmail.com
Mon Sep 19 17:41:43 PDT 2005

Have you tried to do this with formats? I think they're easier to
maintain than a bunch of printf statements. There's a how-to at

On 9/19/05, Adam Monsen <haircut at gmail.com> wrote:
> On 9/19/05, Michael Wallendahl <mwallend at spikus.com> wrote:
> > Hello,
> >
> > I'm wondering if anyone has a suggestions on a good algorithm to
> > 'pretty-print' a nested hash in tabular form?
> [...]
> You could pick a max length for each column, then use substr to
> truncate anything longer than your desired max length. Other than
> that, the algorithm you've implemented looks fine. Any fancy solutions
> (like using a custom tied hash that sorts keys or keeps track of the
> longest value, or something like that) would have to do the same work
> as what you wrote, but would probably be less straightforward to
> maintain. But, of course, YMMV, TMTOWTDI, etc.
> HTH,
> -AMM
> --
> Adam Monsen
> http://adammonsen.com/
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
>     POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>    MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med
>    WEB PAGE: http://seattleperl.org/

More information about the spug-list mailing list