our
$VERSION
=
'1.281'
;
our
@ISA
=
'Exporter'
;
our
@EXPORT_OK
=
qw{ _Document _slurp }
;
use
constant
HAVE_UNICODE
=> !! ( $] >= 5.008007 );
sub
TRUE () { 1 }
sub
FALSE () {
''
}
sub
_Document {
shift
if
@_
> 1;
return
undef
unless
defined
$_
[0];
return
PPI::Document->new(
shift
)
unless
ref
$_
[0];
return
PPI::Document->new(
shift
)
if
_SCALAR0(
$_
[0]);
return
PPI::Document->new(
shift
)
if
_ARRAY0(
$_
[0]);
return
shift
if
_INSTANCE(
$_
[0],
'PPI::Document'
);
return
undef
;
}
sub
_slurp {
my
$file
=
shift
;
local
$/ =
undef
;
local
*FILE
;
open
( FILE,
'<'
,
$file
) or
return
"open($file) failed: $!"
;
my
$source
= <FILE>;
close
( FILE ) or
return
"close($file) failed: $!"
;
return
\
$source
;
}
sub
md5hex {
my
$string
=
shift
;
$string
=~ s/(?:\015{1,2}\012|\015|\012)/\015/gs;
Digest::MD5::md5_hex(
$string
);
}
sub
md5hex_file {
my
$file
=
shift
;
my
$content
= _slurp(
$file
);
return
undef
unless
ref
$content
;
$$content
=~ s/(?:\015{1,2}\012|\015|\012)/\n/gs;
md5hex(
$$content
);
}
1;