use strict; use warnings; use Scalar::Util qw( refaddr ); use Benchmark qw( cmpthese ); my $ref = {}; cmpthese( -5, { 'xs ' => sub { refaddr $ref }, 'regex' => sub { "$ref" =~ /0x(\w+)/; hex $1; }, '0+ref' => sub { 0 + $ref }, });