Skip to content

Instantly share code, notes, and snippets.

@mishin
Forked from knutov/dumper.pl
Last active August 29, 2015 14:19
Show Gist options
  • Save mishin/7b038ba21a085c3f9ac1 to your computer and use it in GitHub Desktop.
Save mishin/7b038ba21a085c3f9ac1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use v5.14;
# cpanm utf8::all Data::Dumper::Perltidy Data::Dumper
use utf8::all;
#===========
# TODO: move to standalone module
use Data::Dumper::Perltidy;
# use Data::Dumper;
$Data::Dumper::Useqq = 1;
{
no warnings 'redefine';
sub Data::Dumper::qquote {
my $s = shift;
return "'$s'";
}
}
# $Data::Dumper::Indent = 3;
$Data::Dumper::Sortkeys = sub {
my $data = join '', keys %{$_[0]};
if ($data !~ /^[0-9]+$/) {
# input is not numeric
return [ sort keys %{$_[0]} ];
} else {
return [ sort { $a <=> $b } keys %{$_[0]} ];
}
};
#===========
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment