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
view release on metacpan or search on metacpan
lib/Ryu/Source.pm view on Meta::CPAN
no indirect;
use sort qw(stable);
use Scalar::Util ();
use Ref::Util ();
use List::Util ();
use List::UtilsBy;
use Encode ();
use Syntax::Keyword::Try;
use Future;
lib/Ryu/Source.pm view on Meta::CPAN
sub flat_map {
my ($self, $code) = splice @_, 0, 2;
# Upgrade ->flat_map(method => args...) to a coderef
if(!Ref::Util::is_plain_coderef($code)) {
my $method = $code;
my @args = @_;
$code = sub { $_->$method(@args) }
}
lib/Ryu/Source.pm view on Meta::CPAN
$add->($self->_completed);
$self->each_while_source(sub {
my $src = $weak_sauce or return;
for ($code->($_)) {
my $item = $_;
if(Ref::Util::is_plain_arrayref($item)) {
$log->tracef("Have an arrayref of %d items", 0 + @$item);
for(@$item) {
last if $src->is_ready;
$src->emit($_);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/SDL2/Utils.pm view on Meta::CPAN
use File::Spec::Functions qw[catdir canonpath rel2abs];
use Path::Tiny qw[path];
use File::Share qw[dist_dir];
use Config;
use SDL2::Utils::Type::Enum;
use Ref::Util qw( is_ref is_plain_arrayref is_plain_hashref );
sub deprecate ($str) {
warnings::warn( 'deprecated', $str ) if warnings::enabled('deprecated');
}
view all matches for this distribution
view release on metacpan or search on metacpan
Added List::Util::forall
Change 273 on 1999/03/21 by <gbarr@pobox.com> (Graham Barr)
Added weaken and isweak to Ref::Util
Change 272 on 1999/03/21 by <gbarr@pobox.com> (Graham Barr)
Add new .pm files to repository
Change 271 on 1999/03/21 by <gbarr@pobox.com> (Graham Barr)
- Split into three packages Ref::Util, List::Util and Scalar::DualVar
- readonly and clock were removed in favor of other modules
Change 270 on 1999/03/21 by <gbarr@pobox.com> (Graham Barr)
Rename package
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Scalar/Util/Reftype.pm view on Meta::CPAN
$rt->hash_object; # true
$rt->class; # "Foo"
=head1 DESCRIPTION
This module is B<DEPRECATED>. Please use L<Ref::Util> instead.
This is an alternate interface to C<Scalar::Util>'s C<reftype> function.
Instead of manual type checking you can just call methods on the result
to see if matches the desired type.
=head1 DEPRECATION NOTICE
This module is B<DEPRECATED>. Please use L<Ref::Util> instead.
=head1 NAME
Scalar::Util::Reftype - Alternate reftype() interface
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Schedule/Activity.pm view on Meta::CPAN
package Schedule::Activity;
use strict;
use warnings;
use Ref::Util qw/is_arrayref is_hashref is_plain_hashref/;
use Schedule::Activity::Annotation;
use Schedule::Activity::Attributes;
use Schedule::Activity::Message;
use Schedule::Activity::Node;
use Schedule::Activity::NodeFilter;
view all matches for this distribution
view release on metacpan or search on metacpan
devel/rdfs.pl view on Meta::CPAN
use List::Util 1.33 qw/ any pairgrep uniqstr /;
use LWP::UserAgent;
use Path::Tiny;
use RDF::Prefixes;
use RDF::Trine;
use Ref::Util qw/ is_plain_arrayref /;
use String::CamelCase qw/ decamelize /;
use Template;
use Text::Wrap qw/ wrap /;
use Types::Standard -types;
use URI;
view all matches for this distribution
view release on metacpan or search on metacpan
"FFI::Platypus" : "1.00",
"File::Basename" : "0",
"File::ShareDir" : "0",
"File::Spec" : "0",
"Path::Tiny" : "0",
"Ref::Util" : "0",
"Sub::Util" : "0",
"feature" : "0",
"perl" : "5.008",
"strict" : "0",
"utf8" : "0",
view all matches for this distribution
view release on metacpan or search on metacpan
"Perl::Tidy" : "20210111",
"Pod::Checker" : "1.74",
"Pod::Coverage::TrustPod" : "0",
"Pod::Tidy" : "0.10",
"Pod::Wordlist" : "0",
"Ref::Util" : "0.112",
"Sub::Quote" : "0",
"Test::CPAN::Changes" : "0.19",
"Test::CPAN::Meta::JSON" : "0.16",
"Test::EOL" : "0",
"Test::Mojibake" : "0",
"utf8" : "0"
}
},
"runtime" : {
"recommends" : {
"Ref::Util" : "0.112",
"Sub::Util" : "1.40"
},
"requires" : {
"B" : "0",
"Carp" : "0",
"class" : "Dist::Zilla::Plugin::Prereqs::Soften",
"config" : {
"Dist::Zilla::Plugin::Prereqs::Soften" : {
"copy_to" : [],
"modules" : [
"Ref::Util",
"Sub::Util"
],
"modules_from_features" : null,
"to_relationship" : "recommends"
}
view all matches for this distribution