| 1 | package CHI::Driver::MemcachedFast::Util; | ||
| 2 | use Data::Dumper; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use base qw(Exporter); | ||
| 6 | |||
| 7 | our @EXPORT_OK = qw( | ||
| 8 | dp | ||
| 9 | require_dynamic | ||
| 10 | ); | ||
| 11 | |||
| 12 | sub _dump_value_with_caller { | ||
| 13 | my ($value) = @_; | ||
| 14 | |||
| 15 | my $dump = | ||
| 16 | Data::Dumper->new( [$value] )->Indent(1)->Sortkeys(1)->Quotekeys(0) | ||
| 17 | ->Terse(1)->Dump(); | ||
| 18 | my @caller = caller(1); | ||
| 19 | return sprintf( "[dp at %s line %d.] [%d] %s\n", | ||
| 20 | $caller[1], $caller[2], $$, $dump ); | ||
| 21 | } | ||
| 22 | |||
| 23 | sub dp { | ||
| 24 | print STDERR _dump_value_with_caller(@_); | ||
| 25 | } | ||
| 26 | |||
| 27 | sub require_dynamic { | ||
| 28 | my ($class) = @_; | ||
| 29 | |||
| 30 | eval "require $class"; ## no critic (ProhibitStringyEval) | ||
| 31 | croak $@ if $@; | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; |