App-after
view release on metacpan or search on metacpan
# sub pretty {
# $_[0]->{pretty} = $_[1] if @_ > 1;
# return $_[0]->{pretty};
# }
#
# sub import {
# my $class = shift;
# my $caller = caller;
# my $opts = {};
# while (@_) {
# my $arg = shift;
# $opts->{$arg} = ref $_[0] ? shift @_ : undef;
# }
# if (exists $opts->{'j'}) {
# my $func = ((ref $opts->{j} eq 'HASH') && $opts->{j}{-as}) || 'j';
# no strict 'refs';
# *{"$caller\::$func"} = subname "$class\::j" => sub {
# my $d = shift;
# return $class->new->encode($d) if ref $d eq 'ARRAY' || ref $d eq 'HASH';
# return $class->new->decode($d);
# };
# delete $opts->{'j'};
# }
# }
#
# __PACKAGE__->import('j');
#
# my $FALSE = bless \(my $false = 0), 'JSON::Tiny::_Bool';
# my $TRUE = bless \(my $true = 1), 'JSON::Tiny::_Bool';
#
# my %ESCAPE = (
# '"' => '"',
# '\\' => '\\',
# '/' => '/',
# 'b' => "\x07",
# 'f' => "\x0C",
# 'n' => "\x0A",
# 'r' => "\x0D",
# 't' => "\x09",
# 'u2028' => "\x{2028}",
# 'u2029' => "\x{2029}"
# );
# my %REVERSE = map { $ESCAPE{$_} => "\\$_" } keys %ESCAPE;
# for (0x00 .. 0x1F, 0x7F) {
# my $k = pack 'C', $_;
# $REVERSE{$k} = sprintf '\u%.4X', $_ unless defined $REVERSE{$k};
# }
#
# my $UTF_PATTERNS = {
# 'UTF-32BE' => qr/^\0\0\0[^\0]/,
# 'UTF-16BE' => qr/^\0[^\0]\0[^\0]/,
# 'UTF-32LE' => qr/^[^\0]\0\0\0/,
# 'UTF-16LE' => qr/^[^\0]\0[^\0]\0/
# };
#
# my $WHITESPACE_RE = qr/[\x20\x09\x0a\x0d]*/;
#
# sub DOES {
# my ($proto, $role) = @_;
# return 1 if $role eq 'Mojo::JSON';
# return $proto->SUPER::DOES($role);
# }
#
# sub decode {
# my ($self, $bytes) = @_;
#
# $self->error(undef);
#
# $self->error('Missing or empty input') and return undef unless $bytes;
#
# $bytes =~ s/^(?:\357\273\277|\377\376\0\0|\0\0\376\377|\376\377|\377\376)//g;
#
# $self->error('Wide character in input') and return undef
# unless utf8::downgrade($bytes, 1);
#
# my $encoding = 'UTF-8';
# $bytes =~ $UTF_PATTERNS->{$_} and $encoding = $_ for keys %$UTF_PATTERNS;
#
# my $d_res = eval { $bytes = Encode::decode($encoding, $bytes, 1); 1 };
# $bytes = undef unless $d_res;
#
# my $res = eval {
# local $_ = $bytes;
#
# m/\G$WHITESPACE_RE/gc;
#
# my $ref;
# if (m/\G\[/gc) { $ref = $self->_decode_array() }
#
# elsif (m/\G\{/gc) { $ref = $self->_decode_object() }
#
# else { $self->_exception('Expected array or object') }
#
# unless (m/\G$WHITESPACE_RE\z/gc) {
# my $got = ref $ref eq 'ARRAY' ? 'array' : 'object';
# $self->_exception("Unexpected data after $got");
# }
#
# $ref;
# };
#
# if (!$res && (my $e = $@)) {
# chomp $e;
# $self->error($e);
# }
#
# return $res;
# }
#
# sub encode {
# my ($self, $ref) = @_;
#
# my $eof = '';
# if ($self->pretty) {
# $self->{_indent} = '';
# $eof .= "\n";
# }
#
# return Encode::encode 'UTF-8', $self->_encode_values($ref).$eof;
# }
#
#
# $string =~ s!([\x00-\x1F\x7F\x{2028}\x{2029}\\"/\b\f\n\r\t])!$REVERSE{$1}!gs;
#
# return "\"$string\"";
# }
#
# sub _encode_values {
# my $self = shift;
# my $value = shift;
#
# if (my $ref = ref $value) {
#
# return $self->_encode_array($value) if $ref eq 'ARRAY';
#
# return $self->_encode_object($value) if $ref eq 'HASH';
#
# return $$value ? 'true' : 'false' if $ref eq 'SCALAR';
# return $value ? 'true' : 'false' if $ref eq 'JSON::Tiny::_Bool';
#
# if (Scalar::Util::blessed $value && (my $sub = $value->can('TO_JSON'))) {
# return $self->_encode_values($value->$sub);
# }
# }
#
# return 'null' unless defined $value;
#
# return 0 + $value
# if B::svref_2object(\$value)->FLAGS & (B::SVp_IOK | B::SVp_NOK);
#
# return $self->_encode_string($value);
# }
#
# sub _exception {
# my $self = shift;
#
# m/\G$WHITESPACE_RE/gc;
#
# my $context = 'Malformed JSON: ' . shift;
# if (m/\G\z/gc) { $context .= ' before end of data' }
# else {
# my @lines = split /\n/, substr($_, 0, pos);
# $context .= ' at line ' . @lines . ', offset ' . length(pop @lines || '');
# }
#
# die "$context\n";
# }
#}
#
#{
# package JSON::Tiny::_Bool;
# no warnings;
# use overload
# '0+' => sub { ${$_[0]} },
# '""' => sub { ${$_[0]} },
# fallback => 1,
# ;
# sub DOES {
# my ($proto, $role) = @_;
# return 1 if $role eq 'Mojo::JSON::_Bool';
# return 1 if $role =~ /^JSON::(?:PP::|XS::)?Boolean$/;
# return $proto->SUPER::DOES($role);
# }
#}
#
#1;
#
#__END__
#
### Local/_pci_check_args.pm ###
#sub _pci_check_args {
# my $args = shift;
# FILL_FROM_POS: {
# 1;
# if (@ARGV > 0) { if (exists $args->{"command"}) { return [400, "You specified --command but also argument #0"]; } else { $args->{"command"} = [splice(@ARGV, 0)]; } }
# }
# my @check_argv = @ARGV;
#
# no warnings ('void');
# require List::Util;
# require Scalar::Util;
# require Time::Duration::Parse::AsHash;
# require Scalar::Util::Numeric::PP;
# require Time::Local;
# my $_sahv_dpath;
# my $_sahv_err;
# if (exists $args->{"all"}) {
# $_sahv_dpath = [];
# (!defined($args->{"all"}) ? 1 :
#
# (
# ((!ref($args->{"all"})) ? 1 : (($_sahv_err //= (@$_sahv_dpath ? '@'.join("",map {"[$_]"} @$_sahv_dpath).": " : "") . "Not of type boolean value"),0))))
# ; if ($_sahv_err) { return [400, "Argument validation failed: $_sahv_err"] }
# }
# if (exists $args->{"command"}) {
# $_sahv_dpath = [];
# ((defined($args->{"command"})) ? 1 : (($_sahv_err //= (@$_sahv_dpath ? '@'.join("",map {"[$_]"} @$_sahv_dpath).": " : "") . "Required but not specified"),0))
#
# &&
#
# ((ref($args->{"command"}) eq 'ARRAY') ? 1 : (($_sahv_err //= (@$_sahv_dpath ? '@'.join("",map {"[$_]"} @$_sahv_dpath).": " : "") . "Not of type array"),0))
#
# &&
#
# (
# ((@{$args->{"command"}} >= 1) ? 1 : (($_sahv_err //= (@$_sahv_dpath ? '@'.join("",map {"[$_]"} @$_sahv_dpath).": " : "") . "Length must be at least 1"),0)))
#
# &&
#
# ([push(@{$_sahv_dpath}, undef), ~~(
# ((!defined(List::Util::first(sub {!(
# ($_sahv_dpath->[-1] = $_),
# ((defined($args->{"command"}->[$_])) ? 1 : (($_sahv_err //= (@$_sahv_dpath ? '@'.join("",map {"[$_]"} @$_sahv_dpath).": " : "") . "Required but not specified"),0))
#
# &&
#
# ((!ref($args->{"command"}->[$_])) ? 1 : (($_sahv_err //= (@$_sahv_dpath ? '@'.join("",map {"[$_]"} @$_sahv_dpath).": " : "") . "Not of type text"),0))
# )}, 0..@{$args->{"command"}}-1))) ? 1 : (($_sahv_err //= (@$_sahv_dpath ? '@'.join("",map {"[$_]"} @$_sahv_dpath).": " : "") . "Not of type text"),0))), pop(@{$_sahv_dpath})]->[1])
# ; if ($_sahv_err) { return [400, "Argument validation failed: $_sahv_err"] }
# }
# if (exists $args->{"delay"}) {
# $_sahv_dpath = [];
( run in 2.231 seconds using v1.01-cache-2.11-cpan-600a1bdf6e4 )