our %EXPORT_TAGS = (
assert => [qw(assert_64bit)],
+ bool => [qw(FALSE TRUE)],
clone => [qw(clone clone_nomagic)],
crypt => [qw(pad_pkcs7)],
debug => [qw(dumper)],
empty => [qw(empty nonempty)],
erase => [qw(erase erase_scoped)],
gzip => [qw(gzip gunzip)],
- io => [qw(read_all)],
+ io => [qw(is_readable is_writable read_all)],
load => [qw(load_optional load_xs try_load_optional)],
search => [qw(query search simple_expression_query)],
text => [qw(snakify trim)],
return 1;
}
-=func clone_nomagic
-
- $clone = clone_nomagic($thing);
+=func clone
-Clone deeply without keeping [most of] the magic.
+ $clone = clone($thing);
-B<NOTE:> At the moment the implementation is naïve and won't respond well to nontrivial data.
+Clone deeply. This is an unadorned alias to L<Storable> C<dclone>.
=cut
goto &Storable::dclone;
}
+=func clone_nomagic
+
+ $clone = clone_nomagic($thing);
+
+Clone deeply without keeping [most of] the magic.
+
+B<WARNING:> At the moment the implementation is naïve and won't respond well to nontrivial data or recursive
+structures.
+
+=cut
+
sub clone_nomagic {
my $thing = shift;
if (is_arrayref($thing)) {
=func dumper
- $str = dumper $struct;
+ $str = dumper $thing;
+ dumper $thing; # in void context, prints to STDERR
Like L<Data::Dumper> but slightly terser in some cases relevent to L<File::KDBX>.
for (@_) {
if (!is_ref($_)) {
next if !defined $_ || readonly $_;
- if (USE_COWREFCNT()) {
+ if (_USE_COWREFCNT()) {
my $cowrefcnt = B::COW::cowrefcnt($_);
goto FREE_NONREF if defined $cowrefcnt && 1 < $cowrefcnt;
}
}
elsif (is_scalarref($_)) {
next if !defined $$_ || readonly $$_;
- if (USE_COWREFCNT()) {
+ if (_USE_COWREFCNT()) {
my $cowrefcnt = B::COW::cowrefcnt($$_);
goto FREE_REF if defined $cowrefcnt && 1 < $cowrefcnt;
}
return $out;
}
-=func gunzip
+=func gzip
$zipped = gzip($string);
return $out;
}
+=func is_readable
+
+=func is_writable
+
+ $bool = is_readable($mode);
+ $bool = is_writable($mode);
+
+Determine of an C<fopen>-style mode is readable, writable or both.
+
+=cut
+
+sub is_readable { $_[0] !~ /^[aw]b?$/ }
+sub is_writable { $_[0] !~ /^rb?$/ }
+
=func is_uuid
$bool = is_uuid($thing);
return $_;
}
+=func uri_unescape_utf8
+
+ $string = uri_unescape_utf8($string);
+
+Inverse of L</uri_escape_utf8>.
+
+=cut
+
sub uri_unescape_utf8 {
local $_ = shift // return;
s/\%([A-Fa-f0-9]{2})/chr(hex($1))/;
}
+=func FALSE
+
+=func TRUE
+
+Constants appropriate for use as return values in functions claiming to return true or false.
+
+=cut
+
+sub FALSE() { !1 }
+sub TRUE() { 1 }
+
BEGIN {
my $use_cowrefcnt = eval { require B::COW; 1 };
- *USE_COWREFCNT = $use_cowrefcnt ? sub() { 1 } : sub() { 0 };
+ *_USE_COWREFCNT = $use_cowrefcnt ? sub() { 1 } : sub() { 0 };
}
### --------------------------------------------------------------------------