Hash-Mogrify
view release on metacpan or search on metacpan
lib/Hash/Mogrify.pm view on Meta::CPAN
$GLOBALMAP = 0;
sub import {
$GLOBALMAP |= FORCE if(grep /:force/, @_);
$GLOBALMAP |= NOWARNING if(grep /:nowarning/, @_);
$GLOBALMAP |= DIEONERR if(grep /:dieonerror/, @_);
Hash::Mogrify->export_to_level(1, @_);
}
sub kmap(&@) {
my $code = shift;
my $hash = $_[0];
my $bitmap;
if(!ref $hash) {
$bitmap = shift if((scalar @_) % 2);
$hash = { @_ };
}
my $temp;
for (keys %{$hash}) {
lib/Hash/Mogrify.pm view on Meta::CPAN
$code->($_, $value);
_double($temp, $_, $bitmap) or return;
$temp->{$_} = $value;
}
%{$hash} = %{$temp};
return %{$hash} if(wantarray);
return $hash;
}
sub vmap(&@) {
my $code = shift;
my $hash = $_[0];
my $bitmap; # we don't use this, but maybe once :)
if(!ref $hash) {
$bitmap = shift if((scalar @_) % 2);
$hash = { @_ };
}
my $temp;
for my $key (keys(%{ $hash })) {
$_ = $hash->{$key};
$code->($key, $_);
$temp->{$key} = $_;
}
%{$hash} = %{$temp};
return %{$hash} if(wantarray);
return $hash;
}
sub hmap(&@) {
my $code = shift;
my $hash = $_[0];
my $bitmap;
if(!ref $hash) {
$bitmap = shift if(@_ % 2);
$hash = { @_ };
}
my $temp;
for my $key (keys(%{ $hash })) {
( run in 1.329 second using v1.01-cache-2.11-cpan-49f99fa48dc )