-
-
Save Util/200051 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; # Evil! | |
# Two notes: | |
# 1) The whole point of Y.pm is that you put your own bag-of-tricks into it. | |
# I have just supplied a starter kit here. | |
# 2) Never use this import technique for anything else; it is *deeply* evil. | |
# Assumes a global hash %h; | |
our %h; | |
# dha - Dump Hash in Alpha order | |
sub dha { | |
for my $k ( sort keys %h ) { | |
printf "%7d\t%s\n", $h{$k}, $k; | |
} | |
} | |
# dhn - Dump Hash in Numeric order | |
sub dhn { | |
for my $k ( sort { $h{$b} <=> $h{$a} } keys %h ) { | |
printf "%7d\t%s\n", $h{$k}, $k; | |
} | |
} | |
sub uniq { | |
my %seen; | |
return grep !$seen{$_}++, @_; | |
} | |
# dd - Data::Dumper | |
# Always uses qq mode. Auto-prints if called in void context. | |
sub dd { | |
require Data::Dumper; | |
$Data::Dumper::Useqq = 1; | |
return Data::Dumper::Dumper(@_) if defined wantarray; | |
print Data::Dumper::Dumper(@_); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment