#!/usr/bin/perl -w
# t_hashdir.pl - test programe for Ext::HashDir
use lib '../libs';
use Ext::HashDir;
use Data::Dumper;
my %map;
my $count = shift || 99999;
print "Running hash table test\n";
for(0...$count) {
my $dir = hashdir(2,1);
if ($map{$dir}) {
$map{$dir} +=1;
} else {
$map{$dir} = 1;
}
}
foreach my $k (sort by_count keys %map) {
print "$k => $map{$k}\n";
}
sub by_count {
$map{$a} <=> $map{$b};
}
sub mymkdir {
my $dir = shift;
my $perm = shift || 0755;
$dir =~ s/^\.?\/+//g;
my @el = split(/\//, $dir);
my $buf = '';
for (@el) {
$buf .= "$_/";
mkdir($buf, $perm);
}
}
syntax highlighted by Code2HTML, v. 0.9.1