Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Created July 5, 2012 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bessarabov/3053055 to your computer and use it in GitHub Desktop.
Save bessarabov/3053055 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use 5.010;
use DDP colored => 1;
use Carp;
use Perl6::Form;
my $ddp_options = {
name => 'var', # name to display on cyclic references
indent => 4, # how many spaces in each indent
hash_separator => ' ', # what separates keys from values
colored => 'auto', # colorize output (1 for always, 0 for never)
index => 1, # display array indices
multiline => 1, # display in multiple lines (see note below)
max_depth => 0, # how deep to traverse the data (0 for all)
sort_keys => 1, # sort hash keys
deparse => 0, # use B::Deparse to expand (expose) subroutines
show_tied => 1, # expose tied variables
show_tainted => 1, # expose tainted variables
show_weak => 1, # expose weak references
print_escapes => 0, # print non-printable chars as "\n", "\t", etc.
quote_keys => 'auto', # quote hash keys (1 for always, 0 for never).
# 'auto' will quote when key is empty/space-only.
caller_info => 0, # include information on what's being printed
use_prototypes => 1, # allow p(%foo), but prevent anonymous data
return_value => 'dump', # what should p() return? See 'Return Value' above.
output => 'stderr',# where to print the output. See
# 'Changing output targets' above.
class_method => '_data_printer', # make classes aware of Data::Printer
# and able to dump themselves.
class => {
internals => 1, # show internal data structures of classes
inherited => 'none', # show inherited methods,
# can also be 'all', 'private', or 'public'.
parents => 1, # show parents?
linear_isa => 1, # show the entire @ISA, linearized
expand => 1, # how deep to traverse the object (in case
# it contains other objects). Defaults to
# 1, meaning expand only itself. Can be any
# number, 0 for no class expansion, and 'all'
# to expand everything.
sort_methods => 1, # sort public and private methods
show_methods => 'all' # method list. Also 'none', 'public', 'private'
}
};
my %lengths;
foreach my $key (keys (%{$ddp_options})) {
$lengths{length($key)}++;
}
print form "{<<<<<<} {<<<<<<}",
'length', 'count';
foreach my $key (sort { $lengths{$b} <=> $lengths{$a} } (keys(%lengths))) {
print form "{<<<<<<} => {<<<<<<}",
$key, $lengths{$key};
}
__END__
output:
length count
9 => 5
12 => 3
6 => 2
7 => 2
14 => 2
5 => 2
11 => 1
4 => 1
10 => 1
13 => 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment