Command line table dumping

petdance on 2004-10-29T15:49:58

Data::Hash::Totals makes it easy for you to do pretty command-line dumping of data, as below:

grep "does not exist" ~/error_log | perl -MData::Hash::Totals -a -F -n -e'++$X{$F[-1]}; END {print as_table(\%X)}' 106 /site/tw/help/images/backgrounds/container.gif 68 /site/tw/graphics//links/close_window.gif 53 /site/tw/bk/map2.html 47 /site/tw/grpahics/links/close_window.gif 21 /site/tw/bk/map3.html 15 /site/tw/lgcover. ...

Note that it requires the latest D:H:T, version 0.02 to work. Good thing I'm uploading that right now.

Addendum: You can leave grep out of it, of course: perl -MData::Hash::Totals -a -F -n -e'++$X{$F[-1]} if /does not exist/; END {print as_table(\%X)}' ~/error_log


Cool!

jordan on 2004-10-31T14:53:01

I do this kind of thing ALL THE TIME, but a lot more verbosely.

Thanks!