Skip to content

Instantly share code, notes, and snippets.

View haukex's full-sized avatar
🍔

Hauke D haukex

🍔
View GitHub Profile
use warnings;
use strict;
use Data::Dumper;
use Memoize::Expire;
tie my %cache => 'Memoize::Expire';
my $self = { cache => [ \%cache ] }; # self is not tied nor an object
eval { print Dumper($self); 1 } or warn $@;
#=> Can't locate object method "FIRSTKEY" via package "Memoize::Expire" at ...
use warnings;
use strict;
use Benchmark qw/cmpthese/;
for my $r (10,100,1_000,10_000) {
print " ___ $r ___\n";
my $str = "foo;bar;" x $r;
cmpthese(-1, {
orig => sub { # https://stackoverflow.com/q/48961457/9300627
$str=~s/\b([^;]+)(?=.*;\1;);//gr;