#!/usr/local/bin/perl -w use strict; use VCP::Debug qw( :debug ); BEGIN { enable_debug ".*"; } use VCP::RevMapDB; my $db = VCP::RevMapDB->new( @ARGV ? ( StoreLoc => shift ) : () ); $db->open_existing_db; my( @keys, %vals ); my @w; while ( my ( $k, $v ) = each %{$db->{Store}->{Hash}} ) { my @key = $db->{Store}->unpack_values( $k ); for ( my $i = 0; $i <= $#key; ++$i ) { $w[$i] = length $key[$i] if ! defined $w[$i] || length $key[$i] > $w[$i]; } push @keys, \@key; $vals{$k} = [ $db->{Store}->unpack_values( $v ) ]; } ## This does not take file separators in to account, but that's ok ## for a debugging tool and the ids that are used as key values ## are supposed to be opaque anyway @keys = sort @keys; my $f = join( " ", map "%-${w[$_]}s", 0..$#w) . " => %s\n"; while ( @keys ) { my @k = @{shift @keys}; my @v = @{$vals{$db->{Store}->pack_values( @k )}}; printf $f, @k, @v == 1 ? $v[0] : join join( ",", @v ), "(", ")"; }