File: Util.pm

package info (click to toggle)
libanyevent-connection-perl 0.06-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 240 kB
  • sloc: perl: 2,560; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package #hide
	AnyEvent::Connection::Util;

use common::sense 2;m{
use strict;
use warnings;
};
use Carp;

sub import {
	my $me = shift;
	my $pk = caller;
	for (@_ ? @_ : qw(dumper)) {
		defined &$_ or croak "$_ is not exported by $me";
		*{$pk.'::'.$_} = \&$_;
	}
	return;
}

sub dumper (@) {
	eval { require Data::Dumper;1 } or return @_;
	no strict 'refs';
	*{ caller().'::dumper' } = sub (@) {
		my $s = Data::Dumper->new([@_])
			#->Maxdepth(3)
			->Terse(1)
			->Indent(1)
			->Purity(0)
			->Useqq(1)
			->Quotekeys(0)
			->Dump;
		$s =~ s{\\x\{([a-f0-9]{1,4})\}}{chr hex $1}sge;
		$s;
	};
	goto &{ caller().'::dumper' };
}

1;