view release on metacpan or search on metacpan
lib/NewsExtractor/SiteSpecificExtractor/news_pts_org_tw.pm view on Meta::CPAN
extends 'NewsExtractor::JSONLDExtractor';
with 'NewsExtractor::Role::ContentTextExtractor';
use HTML::ExtractContent;
use Importer 'NewsExtractor::TextUtil' => ('html2text', 'reformat_dateline');
use Importer 'Ref::Util' => ('is_hashref');
sub journalist {
my ($self) = @_;
my $name;
my $author = $self->schema_ld->{author};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/JSON/Schema/Modern/Document/OpenAPI.pm view on Meta::CPAN
use Digest::MD5 'md5_hex';
use Storable 'dclone';
use File::ShareDir 'dist_dir';
use Path::Tiny;
use List::Util 'pairs';
use Ref::Util 'is_plain_hashref';
use MooX::TypeTiny 0.002002;
use Types::Standard qw(InstanceOf HashRef Str Enum);
use namespace::clean;
extends 'JSON::Schema::Modern::Document';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/OpenTelemetry/Exporter/OTLP/Encoder/JSON.pm view on Meta::CPAN
our $VERSION = '0.021';
class OpenTelemetry::Exporter::OTLP::Encoder::JSON {
use JSON::MaybeXS;
use OpenTelemetry::Constants 'HEX_INVALID_SPAN_ID';
use Ref::Util qw( is_hashref is_arrayref );
use Scalar::Util 'refaddr';
use isa 'OpenTelemetry::SDK::Logs::LogRecord';
method content_type () { 'application/json' }
view all matches for this distribution
view release on metacpan or search on metacpan
lib/OpenTelemetry/SDK/Trace/Span.pm view on Meta::CPAN
class OpenTelemetry::SDK::Trace::Span
:isa(OpenTelemetry::Trace::Span)
:does(OpenTelemetry::Attributes)
{
use List::Util qw( any pairs );
use Ref::Util qw( is_arrayref is_hashref );
use Time::HiRes 'time';
use OpenTelemetry::Constants
-span_kind => { -as => sub { shift =~ s/^SPAN_KIND_//r } };
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Log/Any/Adapter/OpenTelemetry.pm view on Meta::CPAN
our $VERSION = '0.030';
use Log::Any::Adapter::Util ();
use OpenTelemetry qw( otel_config otel_span_from_context otel_logger_provider );
use Ref::Util 'is_hashref';
use Time::HiRes 'time';
use OpenTelemetry::Constants qw(
LOG_LEVEL_TRACE
LOG_LEVEL_DEBUG
view all matches for this distribution
view release on metacpan or search on metacpan
lib/OpenTracing/Implementation/DataDog/Span.pm view on Meta::CPAN
with 'OpenTracing::Role::Span';
use aliased 'OpenTracing::Implementation::DataDog::SpanContext';
use Types::Standard qw/Str/;
use Ref::Util qw/is_plain_hashref/;
use Carp;
=head1 DESCRIPTION
This is a L<OpenTracing Span|OpenTracing::Interface::Span> compliant
view all matches for this distribution
view release on metacpan or search on metacpan
lib/OpenTracing/Role/Tracer.pm view on Meta::CPAN
use MooX::Should;
use Carp;
use List::Util qw/first/;
use OpenTracing::Types qw/ScopeManager Span SpanContext is_Span is_SpanContext/;
use Ref::Util qw/is_plain_hashref/;
use Role::Declare::Should -lax;
use Try::Tiny;
use Types::Common::Numeric qw/PositiveOrZeroNum/;
use Types::Standard qw/ArrayRef CodeRef Dict HashRef InstanceOf Maybe Object Str Undef/;
use Types::TypeTiny qw/TypeTiny/;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/PDL/Algorithm/Center.pm view on Meta::CPAN
use Carp;
use Try::Tiny;
use Safe::Isa;
use Ref::Util qw< is_arrayref is_ref is_coderef is_hashref >;
use Hash::Wrap ( { -as => '_wrap_hash' } );
use PDL::Algorithm::Center::Failure ':all';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/PDLx/Mask.pm view on Meta::CPAN
use v5.10;
our $VERSION = '0.06';
use Params::Check qw[ check ];
use Ref::Util ':all';
use Data::GUID;
use Safe::Isa;
use PDL::Core ':Internal';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/PGObject/Type/ByteString.pm view on Meta::CPAN
use warnings;
use 5.010;
use Carp;
use DBD::Pg qw(:pg_types);
use Ref::Util qw(is_ref is_scalarref);
=head1 NAME
PGObject::Type::ByteString - Wrapper for raw strings mapping to BYTEA columns.
view all matches for this distribution
view release on metacpan or search on metacpan
bin/file-to-elasticsearch.pl view on Meta::CPAN
use JSON::MaybeXS qw(decode_json encode_json);
use Log::Log4perl qw(:easy);
use Module::Load qw(load);
use Module::Loaded qw(is_loaded);
use Pod::Usage;
use Ref::Util qw(is_arrayref is_hashref);
use YAML ();
sub POE::Kernel::ASSERT_DEFAULT { 1 }
use POE qw(
Component::ElasticSearch::Indexer
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Package/Checkpoint.pm view on Meta::CPAN
use warnings;
use 5.020;
use experimental qw( postderef signatures );
use Package::Stash;
use Storable qw( dclone );
use Ref::Util qw( is_ref );
# ABSTRACT: Checkpoint the scalar, array and hash values in a package for later restoration
our $VERSION = '0.01'; # VERSION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Parse/Syslog/Line.pm view on Meta::CPAN
use Hash::Merge::Simple qw( dclone_merge );
use JSON::MaybeXS qw( decode_json );
use Module::Load qw( load );
use Module::Loaded qw( is_loaded );
use POSIX qw( strftime tzset );
use Ref::Util qw( is_arrayref );
use Time::Moment;
# RECOMMEND PREREQ: Cpanel::JSON::XS
our $VERSION = '6.2';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Pcore/Util/Scalar.pm view on Meta::CPAN
package Pcore::Util::Scalar;
use Pcore -export;
use Scalar::Util qw[blessed dualvar isdual readonly refaddr reftype tainted weaken isweak isvstring looks_like_number set_prototype]; ## no critic qw[Modules::ProhibitEvilModules]
use Devel::Refcount qw[refcount];
use Ref::Util qw[:all];
our $EXPORT = {
ALL => [qw[looks_like_uuid]],
SCALAR => [qw[blessed refaddr reftype weaken isweak looks_like_number tainted refcount is_glob]],
REF => [qw[is_ref is_scalarref is_arrayref is_hashref is_coderef is_regexpref is_globref is_formatref is_ioref is_refref is_plain_ref is_plain_scalarref is_plain_arrayref is_plain_hashref is_plain_coderef is_plain_globref is_plain_formatref is...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Perl/Critic/Policy/References/ProhibitRefChecks.pm view on Meta::CPAN
Perl::Critic::Policy::References::ProhibitRefChecks - Write C<is_arrayref($var)> instead of C<ref($var) eq 'ARRAY'>.
=head1 DESCRIPTION
Checking references manually is less efficient that using L<Ref::Util> and prone to typos.
if(ref($var) eq 'ARRYA') # oops!
if(is_arrayref($var)) # ok
if(ref($var) ne 'HASH') # no
lib/Perl/Critic/Policy/References/ProhibitRefChecks.pm view on Meta::CPAN
Regular expression matches are violations by default. To permit checks of the form C<ref(...) =~ /pattern/> or C<!~>:
[References::ProhibitRefChecks]
regexp = 1
Since L<Ref::Util> provides C<is_ref>, in the default configuration the bare C<ref> call is rarely needed. To specifically permit using direct C<ref(...)> calls:
[References::ProhibitRefChecks]
bareref = 1
=head1 NOTES
view all matches for this distribution
view release on metacpan or search on metacpan
local/lib/perl5/Specio.pm view on Meta::CPAN
There are several optional prereqs that if installed will make this
distribution better in some way.
=over 4
=item * L<Ref::Util>
Installing this will speed up a number of type checks for built-in types.
=item * L<XString>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/Prerender.pm view on Meta::CPAN
use HTTP::Request;
use HTTP::Status qw/ :constants /;
use Plack::Request;
use Plack::Util;
use Plack::Util::Accessor qw/ mech rewrite cache max_age request response wait /;
use Ref::Util qw/ is_coderef is_plain_arrayref /;
use Time::Seconds qw/ ONE_HOUR /;
use WWW::Mechanize::Chrome;
# RECOMMEND PREREQ: CHI
# RECOMMEND PREREQ: Log::Log4perl
# RECOMMEND PREREQ: Ref::Util::XS
sub prepare_app {
my ($self) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/Middleware/Greylist.pm view on Meta::CPAN
package Plack::Middleware::Greylist;
# ABSTRACT: throttle requests with different rates based on net blocks
# RECOMMEND PREREQ: Cache::FastMmap 1.52
# RECOMMEND PREREQ: Ref::Util::XS
use v5.20;
use warnings;
use parent qw( Plack::Middleware );
lib/Plack/Middleware/Greylist.pm view on Meta::CPAN
use List::Util 1.29 qw/ pairs /;
use Module::Load qw/ load /;
use Net::IP::LPM;
use Plack::Util;
use Plack::Util::Accessor qw/ default_rate rules cache file _match greylist retry_after cache_config callback /;
use Ref::Util qw/ is_plain_arrayref is_coderef /;
use Time::Seconds qw/ ONE_MINUTE /;
use experimental qw/ postderef signatures /;
our $VERSION = 'v0.8.1';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/Middleware/Security/Simple.pm view on Meta::CPAN
use parent qw( Plack::Middleware );
use Hash::Match;
use HTTP::Status qw( HTTP_BAD_REQUEST );
use Ref::Util qw/ is_plain_arrayref is_plain_hashref /;
use Plack::Response;
use Plack::Util::Accessor qw( rules handler status );
# RECOMMEND PREREQ: Ref::Util::XS
our $VERSION = 'v0.13.0';
sub prepare_app {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/Middleware/Statsd.pm view on Meta::CPAN
# ABSTRACT: send statistics to statsd
# RECOMMEND PREREQ: Net::Statsd::Tiny v0.3.0
# RECOMMEND PREREQ: HTTP::Status 6.16
# RECOMMEND PREREQ: List::Util::XS
# RECOMMEND PREREQ: Ref::Util::XS
use v5.20;
use warnings;
use parent qw/ Plack::Middleware /;
use List::Util qw/ first /;
use Plack::Util;
use Plack::Util::Accessor
qw/ client sample_rate histogram increment set_add catch_errors /;
use Ref::Util qw/ is_coderef /;
use Time::HiRes;
use Try::Tiny;
use experimental qw/ postderef signatures /;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/Middleware/Text/Minify.pm view on Meta::CPAN
use parent qw/ Plack::Middleware /;
use Plack::Util;
use Plack::Util::Accessor qw/ path type /;
use Ref::Util qw/ is_arrayref is_coderef /;
use Text::Minify::XS v0.7.0 ();
# RECOMMEND PREREQ: Ref::Util::XS
our $VERSION = 'v0.4.1';
sub call {
my ($self, $env) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/Middleware/Zstandard.pm view on Meta::CPAN
# ABSTRACT: Compress response body with Zstandard
use parent qw( Plack::Middleware );
use Plack::Util ();
use Plack::Util::Accessor qw( level _constructor_args vary );
use Ref::Util qw( is_plain_arrayref );
use Compress::Stream::Zstd::Compressor ();
sub prepare_app ($self) {
if(defined $self->level) {
$self->_constructor_args([$self->level]);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plift/Context.pm view on Meta::CPAN
use Carp;
use XML::LibXML::jQuery;
use JSON 'to_json';
use Encode 'encode';
use namespace::clean;
use Ref::Util qw/ is_hashref is_blessed_ref /;
has 'helper', is => 'ro';
has 'wrapper', is => 'ro';
has 'template', is => 'ro', required => 1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Pod/Elemental/Transformer/Splint.pm view on Meta::CPAN
use Safe::Isa;
use Try::Tiny;
use List::UtilsBy 'extract_by';
use Types::Standard qw/Str ArrayRef HashRef/;
use Module::Load qw/load/;
use Ref::Util qw/is_arrayref/;
use lib 'lib';
with qw/Pod::Elemental::Transformer Pod::Elemental::Transformer::Splint::Util/;
has command_name => (
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Qhull/PP.pm view on Meta::CPAN
our $VERSION = '0.07';
use Exporter::Shiny 'qhull';
use Scalar::Util 'blessed';
use Ref::Util 'is_arrayref';
use List::Util 'any';
use Log::Any '$log';
use Eval::Closure 'eval_closure';
use Ref::Util 'is_hashref', 'is_plain_arrayref';
use File::Spec;
use Qhull::Util 'parse_output';
use Qhull::Util::Options 'CAT_OUTPUT_FORMAT';
use Qhull::Options;
use System::Command;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/RPMVerify.pm view on Meta::CPAN
use warnings;
no warnings qw{experimental};
use feature qw{signatures};
use Ref::Util qw{is_arrayref};
use List::Util qw{any};
use File::Which qw{which};
sub alterations(%options) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Ref/Util/Rewriter.pm view on Meta::CPAN
package Ref::Util::Rewriter;
# ABSTRACT: Rewrite your code to use Ref::Util
use strict;
use warnings;
use PPI;
lib/Ref/Util/Rewriter.pm view on Meta::CPAN
=encoding UTF-8
=head1 NAME
Ref::Util::Rewriter - Rewrite your code to use Ref::Util
=head1 VERSION
version 0.100
=head1 SYNOPSIS
use Ref::Util::Rewriter qw< rewrite_string >;
my $new_string = rewrite_string(
q! if ( ref($foo) eq 'HASH' ) { ... } !
);
# $new_string = q! if ( is_hashref($foo) ) { ... } !;
use Ref::Util::Rewriter qw< rewrite_file >;
rewrite_file("script.pl"); # file was now rewritten
=head1 DESCRIPTION
B<Warning:> You should take into account that the meaning of
L<Ref::Util>'s functions are subject to change with regards to
blessed objects. This might change the rewriter code in the future
to be smarter. This might also mean this won't necessarily achieve
what you're expecting.
Run it, check the diff, check your code, run your code, then
(maybe) - knowing the risk you take and absolutely no liability on
me, my family, nor my pets - merge it.
This module rewrites Perl code to use L<Ref::Util> instead of your
regular calls to C<ref>. It is much substantially faster and avoids
several mistakes that haunt beginning and advanced Perl developers.
Please review L<Ref::Util> to fully understand the possible implications
of using it in your case instead of the built-in C<ref> function.
The following constructs of code are supported:
=over 4
lib/Ref/Util/Rewriter.pm view on Meta::CPAN
=head1 SUBROUTINES
=head2 rewrite_string($perl_code_string)
Receive a string representing Perl code and return a new string in which
all C<ref> calls are replaced with the appropriate calls to L<Ref::Util>.
=head2 rewrite_file($filename)
Receive a filename as a string and rewrite the file in place (thus the
file is altered) in which all C<ref> calls are replaced with the
appropriate calls to L<Ref::Util>.
Careful, this function changes your file in place. It is advised to put
your file in some revision control so you could see what changes it has
done and commit them if you accept them.
This does B<not> add a new statement to use L<Ref::Util>, you will still
need to do that yourself.
=head2 rewrite_doc
The guts of the module which uses a direct L<PPI::Document> object and
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Ref/Util/XS.pm view on Meta::CPAN
package Ref::Util::XS;
# ABSTRACT: XS implementation for Ref::Util
$Ref::Util::XS::VERSION = '0.117';
use strict;
use warnings;
use XSLoader;
use Exporter 5.57 'import';
lib/Ref/Util/XS.pm view on Meta::CPAN
is_blessed_refref
>] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
XSLoader::load('Ref::Util::XS', $Ref::Util::XS::{VERSION} ? ${ $Ref::Util::XS::{VERSION} } : ());
if (_using_custom_ops()) {
for my $op (@{$EXPORT_TAGS{all}}) {
no strict 'refs';
*{"B::Deparse::pp_$op"} = sub {
lib/Ref/Util/XS.pm view on Meta::CPAN
=encoding UTF-8
=head1 NAME
Ref::Util::XS - XS implementation for Ref::Util
=head1 VERSION
version 0.117
=head1 SYNOPSIS
use Ref::Util;
# Don't use Ref::Util::XS directly!
if (is_arrayref($something) {
print for @$something;
}
elsif (is_hashref($something)) {
print for sort values %$something;
}
=head1 DESCRIPTION
Ref::Util::XS is the XS implementation of Ref::Util, which provides several
functions to help identify references in a more convenient way than the
usual approach of examining the return value of C<ref>.
You should use L<Ref::Util::XS> by installing L<Ref::Util> itself: if the system
you install it on has a C compiler available, C<Ref::Util::XS> will be
installed and used automatically, providing a significant speed boost to
everything that uses C<Ref::Util>.
See L<Ref::Util> for full documentation of the available functions.
=head1 THANKS
The following people have been invaluable in their feedback and support.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Ref/Util.pm view on Meta::CPAN
package Ref::Util;
# ABSTRACT: Utility functions for checking references
$Ref::Util::VERSION = '0.204';
use strict;
use warnings;
use Exporter 5.57 'import';
{
my $impl = $ENV{PERL_REF_UTIL_IMPLEMENTATION}
|| our $IMPLEMENTATION
|| 'XS';
if ($impl ne 'PP' && eval { require Ref::Util::XS; 1 }) {
_install_aliases('Ref::Util::XS');
}
else {
require Ref::Util::PP;
_install_aliases('Ref::Util::PP');
}
}
sub _install_aliases {
my ($package) = @_;
lib/Ref/Util.pm view on Meta::CPAN
=encoding UTF-8
=head1 NAME
Ref::Util - Utility functions for checking references
=head1 VERSION
version 0.204
=head1 SYNOPSIS
use Ref::Util qw( is_plain_arrayref is_plain_hashref );
if ( is_plain_arrayref( $something ) ) {
print for @{ $something };
} elsif ( is_plain_hashref( $something ) ) {
print for sort values %{ $something };
}
=head1 DESCRIPTION
Ref::Util introduces several functions to help identify references in a
B<smarter> (and usually faster) way. In short:
# conventional approach # with Ref::Util
ref( $foo ) eq 'ARRAY' is_plain_arrayref( $foo )
use Scalar::Util qw( reftype );
reftype( $foo ) eq 'ARRAY' is_arrayref( $foo )
lib/Ref/Util.pm view on Meta::CPAN
so even if it's blessed, you know what type of variable is blessed.
my $foo = bless {}, 'PKG';
ref($foo) eq 'HASH'; # fails
use Ref::Util 'is_hashref';
my $foo = bless {}, 'PKG';
is_hashref($foo); # works
On the other hand, in some situations it might be better to specifically
exclude blessed references. The rationale for that might be that merely
lib/Ref/Util.pm view on Meta::CPAN
=item * Supports tied variables and magic
Tied variables (used in L<Readonly>, for example) are supported.
use Ref::Util qw<is_plain_hashref>;
use Readonly;
Readonly::Scalar my $rh2 => { a => { b => 2 } };
is_plain_hashref($rh2); # success
L<Ref::Util> added support for this in 0.100. Prior to this version
the test would fail.
=item * Ignores overloading
These functions ignore overloaded operators and simply check the
lib/Ref/Util.pm view on Meta::CPAN
Support might be added, if a good reason arises.
=item * Usually fast
When possible, Ref::Util uses L<Ref::Util::XS> as its implementation. (If
you don't have a C compiler available, it uses a pure Perl fallback that has
all the other advantages of Ref::Util, but isn't as fast.)
In fact, Ref::Util::XS has two alternative implementations available
internally, depending on the features supported by the version of Perl
you're using. For Perls that supports custom OPs, we actually add an OP
(which is faster); for other Perls, the implementation that simply calls an
XS function (which is still faster than the pure-Perl equivalent).
lib/Ref/Util.pm view on Meta::CPAN
=head1 EXPORT
Nothing is exported by default. You can ask for specific subroutines
(described below) or ask for all subroutines at once:
use Ref::Util qw<is_scalarref is_arrayref is_hashref ...>;
# or
use Ref::Util ':all';
=head1 SUBROUTINES
=head2 is_ref($ref)
lib/Ref/Util.pm view on Meta::CPAN
my $amount = 1e7;
my $ref = [];
$bench->add_instances(
Dumbbench::Instance::PerlSub->new(
name => 'Ref::Util::is_plain_arrayref (CustomOP)',
code => sub {
Ref::Util::is_plain_arrayref($ref) for ( 1 .. $amount )
},
),
Dumbbench::Instance::PerlSub->new(
name => 'ref(), reftype(), !blessed()',
lib/Ref/Util.pm view on Meta::CPAN
The results:
ref(): 5.335e+00 +/- 1.8e-02 (0.3%)
ref(), reftype(), !blessed(): 1.5545e+01 +/- 3.1e-02 (0.2%)
Ref::Util::is_plain_arrayref (CustomOP): 2.7951e+00 +/- 6.2e-03 (0.2%)
Data::Util::is_array_ref: 5.9074e+00 +/- 7.5e-03 (0.1%)
(Rounded run time per iteration)
A benchmark against L<Data::Util>:
Ref::Util::is_plain_arrayref: 3.47157e-01 +/- 6.8e-05 (0.0%)
Data::Util::is_array_ref: 6.7562e-01 +/- 7.5e-04 (0.1%)
=head1 SEE ALSO
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Robots/Validate.pm view on Meta::CPAN
use Moo 1;
use MooX::Const v0.4.0;
use List::Util 1.33 qw/ first none /;
use Net::DNS::Resolver;
use Ref::Util qw/ is_plain_hashref /;
use Types::Standard -types;
# RECOMMEND PREREQ: Type::Tiny::XS
# RECOMMEND PREREQ: Ref::Util::XS
use namespace::autoclean;
our $VERSION = 'v0.2.9';
view all matches for this distribution