This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
NewerOlder