Acme-Tools
view release on metacpan or search on metacpan
my $dice = random(1,6);
my $color = random(['red','green','blue','yellow','orange']);
pushr $arrayref[$num], @stuff; # push @{ $arrayref[$num] }, @stuff ... popr, shiftr, unshiftr
print 2**200; # 1.60693804425899e+60
print big(2)**200; # 1606938044258990275541962092341162602522202993782792835301376
...and much more.
=encoding utf8
=head1 ABSTRACT
About 120 more or less useful perl subroutines lumped together and exported into your namespace.
=head1 DESCRIPTION
Subs created and collected since the mid-90s.
=head1 INSTALLATION
# - http://cpants.cpanauthors.org/dist/Acme-Tools #kvalitee
# - perl Makefile.PL && make test && make dist
# - cp -p *tar.gz /htdocs/
# - #ci -l -mversjon -d `cat MANIFEST` #no
# - git add `cat MANIFEST`
# - git status
# - git commit -am versjon
# - git push #eller:
# - git push origin master
# - http://pause.perl.org/
# - tegnsett/utf8-kroell
# - https://rt.cpan.org/Dist/Display.html?Queue=Acme-Tools
# http://en.wikipedia.org/wiki/Birthday_problem#Approximations
# memoize_expire() http://perldoc.perl.org/Memoize/Expire.html
# memoize_file_expire()
# memoize_limit_size() #lru
# memoize_file_limit_size()
# memoize_memcached http://search.cpan.org/~dtrischuk/Memoize-Memcached-0.03/lib/Memoize/Memcached.pm
# hint on http://perl.jonallen.info/writing/articles/install-perl-modules-without-root
# push @lookup_table, $x;
# }
# my $crc = $init_value ^ 0xffffffff;
# foreach my $x (unpack ('C*', $input)) {
# $crc = (($crc >> 8) & 0xffffff) ^ $lookup_table[ ($crc ^ $x) & 0xff ];
# }
# $crc = $crc ^ 0xffffffff;
# return $crc;
# }
#
# $maybe_valid_utf8 =~ # https://stackoverflow.com/questions/11709410/regex-to-detect-invalid-utf-8-string
# m/\A(
# [\x09\x0A\x0D\x20-\x7E] # ASCII, or rather: [\x00-\x7F]
# | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
# | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
# | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
# | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
# | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
# | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
# | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
# )*\z/x;
t/02_general.t view on Meta::CPAN
ok(tablestring(\@reportD) eq <<'', 'pivot D');
Name Height Height Height Height Weight Weight Weight Weight
1997 1997 1998 1998 1997 1997 1998 1998
Summer Winter Summer Winter Summer Winter Summer Winter
----- ------ ------ ------ ------ ------ ------ ------ ------
Gina 170 158 171 171 66 64 64 64
Hilde 168 164 168 168 62 61 62 62
Per 182 180 182 183 75 73 76 74
Tone 70 69 70 0
#-- upper, lower (utf8?)
#ok(upper('a-zæøåäëïöüÿâêîôûãõà èìòùáéÃóúýñð' x 3) eq 'A-ZÃÃÃ
ÃÃÃÃÃÿÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ' x 3, 'upper'); #hmm ÿ
#ok(lower('A-ZÃÃÃ
ÃÃÃÃÃ.ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ' x 3) eq 'a-zæøåäëïöü.âêîôûãõà èìòùáéÃóúýñð' x 3, 'lower'); #hmm .
ok(upper('a-zæøåäëïöü.âêîôûãõà èìòùáéÃóúýñð' x 3) eq 'A-ZÃÃÃ
ÃÃÃÃÃ.ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ' x 3, 'upper'); #hmm ÿ
ok(lower('A-ZÃÃÃ
ÃÃÃÃßÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ' x 3) eq 'a-zæøåäëïöüŸâêîôûãõà èìòùáéÃóúýñð' x 3, 'lower'); #hmm Ÿ â Ÿ
#--time_fp
ok( time_fp() =~ /^\d+\.\d+$/ , 'time_fp' );
#-fails on many systems...virtual boxes?
( run in 0.650 second using v1.01-cache-2.11-cpan-49f99fa48dc )