new search engine stuff
This commit is contained in:
parent
9a4972f3da
commit
18060d8e4e
7 changed files with 91 additions and 323 deletions
|
|
@ -23,7 +23,7 @@ use Tie::IxHash;
|
|||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &commify &randomizeArray
|
||||
&formatBytes &sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round
|
||||
&fromBase36 &toBase36);
|
||||
);
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -39,7 +39,6 @@ This package provides miscellaneous but useful utilities to the WebGUI programme
|
|||
use WebGUI::Utility;
|
||||
$string = commify($integer);
|
||||
$size = formatBytes($integer);
|
||||
$number = fromBase36($string);
|
||||
$boolean = isIn($value, @array);
|
||||
makeArrayCommaSafe(\@array);
|
||||
makeArrayTabSafe(\@array);
|
||||
|
|
@ -50,7 +49,6 @@ This package provides miscellaneous but useful utilities to the WebGUI programme
|
|||
$hashRef = randomizeHash(\%hash);
|
||||
%hash = sortHash(%hash);
|
||||
%hash = sortHashDescending(%hash);
|
||||
$string = toBase36($number);
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
|
|
@ -101,27 +99,6 @@ sub formatBytes {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 fromBase36 ( string )
|
||||
|
||||
Returns a number that has been decoded from base36.
|
||||
|
||||
=head3 string
|
||||
|
||||
A base 36 encoded string.
|
||||
|
||||
=cut
|
||||
|
||||
sub fromBase36 {
|
||||
my $string = shift;
|
||||
my $exponent = 0;
|
||||
my $number;
|
||||
for (reverse split //, $string) {
|
||||
$number += ($_ =~ /\d/ ? $_ : (ord($_) - 87)) * (36**$exponent++);
|
||||
}
|
||||
return $number;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -385,29 +362,6 @@ sub sortHashDescending {
|
|||
return %newHash;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toBase36 ( number )
|
||||
|
||||
Returns a string that is base36 encoded.
|
||||
|
||||
=head3 number
|
||||
|
||||
A number that you wish to encode.
|
||||
|
||||
=cut
|
||||
|
||||
sub toBase36 {
|
||||
my $number = shift;
|
||||
my $string = "";
|
||||
while ($number) {
|
||||
my $quot = $number % 36;
|
||||
$string = ($quot < 10 ? $quot : chr($quot + 87)) . $string;
|
||||
$number = int($number / 36);
|
||||
}
|
||||
$string = "0$string" while length($string) < 9;
|
||||
$string;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue