Data::DigestPath - the path generator as digest hash
use Data::DigestPath; my $dp = Data::DigestPath->new; my $path = $dp->make_path('foo'); # a/c/b/d/acbd18db4cc2f85cedef654fccc4a4d8
There are all options.
use Digest::SHA1 qw//; use Data::DigestPath; my $dp = Data::DigestPath->new( salt => 'bar', depth => 2, delim => '-', digest => sub { Digest::SHA1::sha1_hex(@_) }, ); warn $dp->make_path('baz'); # 3-2-32b1bf1853e6c39e4a1c3dae941ab7094ff1d293
Data::DigestPath makes the path as digest hash.
the object constructor
salt => $string // ''
depth => $integer // 4
delim => $string // '/'
digest => $code_ref // sub { Digest::MD5::md5_hex(@_) }
trancate => $bool // undef
If you set the trancate param TRUE value, then the last delimited string will trancate(= remove the delimited path strings from last string)
use Data::DigestPath; my $dp = Data::DigestPath->new; warn $dp->make_path; # d/4/1/d/d41d8cd98f00b204e9800998ecf8427e $dp->trancate(1); warn $dp->make_path; # d/4/1/d/8cd98f00b204e9800998ecf8427e
generate the path
$key => $string // ''
$length => $file_length // full length
Data::DigestPath is hosted on github <http://github.com/bayashi/Data-DigestPath>
Welcome your patches and issues :D
Dai Okabayashi <bayashi@cpan.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Data::DigestPath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::DigestPath
CPAN shell
perl -MCPAN -e shell install Data::DigestPath
For more information on module installation, please visit the detailed CPAN module installation guide.