view release on metacpan or search on metacpan
AsUTF8Bytes.xs view on Meta::CPAN
if (sv_isobject (ref))
{
sv_bless (clone, SvSTASH (SvRV (ref)));
}
if (SvWEAKREF(ref)) {
sv_rvweaken(clone);
}
}
TRACEME(("clone = 0x%x(%d)\n", clone, SvREFCNT(clone)));
return clone;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Clone/Closure.pm view on Meta::CPAN
refers to, and if there are no strong refs to this new object it will
self-destruct before C<clone> returns. For example,
my $sv = 5;
my $ref = \$sv;
weaken $ref;
my $clone = clone $ref;
will result in $clone being C<undef>, as the new clone of $sv has no
(strong) referents. As weakrefs are normally used to break loops in
self-referential structures, this should not happen often.
view all matches for this distribution
view release on metacpan or search on metacpan
my $clone = clone($a);
# Circular structure is preserved in the clone
=head2 Cloning Weakened References
use Scalar::Util 'weaken';
my $obj = { data => 'important' };
my $container = { strong => $obj, weak => $obj };
weaken($container->{weak});
my $clone = clone($container);
# Both strong and weak references are preserved correctly
=head2 Cloning Tied Variables
Other modules that may be of interest:
L<Clone::PP> - Pure Perl implementation of Clone
L<Scalar::Util> - For C<weaken()> and other scalar utilities
L<Data::Dumper> - For debugging and inspecting data structures
=head1 SUPPORT
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Closure/Explicit.pm view on Meta::CPAN
};
# This will not raise the exception because $self is whitelisted
my $code = callback {
$self->method;
} [qw($self)];
# This will wrap the coderef so we can pass a weakened copy of $self
my $code = callback {
my $self = shift;
$self->method;
} weaken => [qw($self)];
=head1 DESCRIPTION
Attempts to provide some very basic protection against unintentional
capturing of lexicals in a closure.
lib/Closure/Explicit.pm view on Meta::CPAN
use parent qw(Exporter);
our @EXPORT_OK = qw(callback);
# This is not documented, because turning it off will break
# the weaken behaviour.
use constant CLOSURE_CHECKS => exists($ENV{PERL_CLOSURE_EXPLICIT_CHECKS}) ? $ENV{PERL_CLOSURE_EXPLICIT_CHECKS} : 1;
=head1 EXPORTS
=cut
lib/Closure/Explicit.pm view on Meta::CPAN
or a list of named parameters:
=over 4
=item * weaken => [...] - list of B<variable names> which will be copied, weakened
via L<Scalar::Util/weaken>, then prepended to the parameter list available in @_
in your code block
=item * allowed => [...] - list of B<variable names> to ignore if used in the code,
same behaviour as passing a single arrayref
lib/Closure/Explicit.pm view on Meta::CPAN
For example, a method call might look like this:
my $code = callback {
my $self = shift;
$self->method(@_);
} weaken => [qw($self)];
although L<curry::weak> would be a much cleaner alternative there:
my $code = $self->curry::weak::method;
You can mix C<weaken> and C<allowed>:
my $x = 1;
my $code = callback {
shift->method(++$x);
} weaken => [qw($self)], allowed => [qw($x)];
=cut
sub callback(&;@) {
if(CLOSURE_CHECKS) {
lib/Closure/Explicit.pm view on Meta::CPAN
warn "$_\n" for @err;
die "Had " . @err . " error(s) in closure";
}
return $code
} else {
return $_[0] unless grep $_ eq 'weaken', @_;
my $code = shift;
my %spec = @_;
if($spec{weaken}) {
my $scope = peek_my(1);
my @extra = map ${ $scope->{$_} }, @{$spec{weaken}};
Scalar::Util::weaken($_) for @extra;
return sub { $code->(@extra, @_) };
}
}
}
lib/Closure/Explicit.pm view on Meta::CPAN
but if you just want to get a list of potential problems for a coderef,
call this:
my @errors = lint($code, allowed => [qw($x)]);
It's unlikely that the C<weaken> parameter will work when calling this
function directly - this may be fixed in a future version.
=cut
sub lint {
lib/Closure/Explicit.pm view on Meta::CPAN
} keys %closed;
# This is everything we declare in the sub
my @lexicals = grep !exists $closed{$_}, keys %{ peek_sub $code };
if($spec{weaken}) {
# warn "weaken request: " . join ',', @{$spec{weaken}};
my $scope = peek_my(2);
my $real_code = $code;
my @extra = map ${ $scope->{$_} }, @{$spec{weaken}};
Scalar::Util::weaken($_) for @extra;
$code = $_[0] = sub { $real_code->(@extra, @_) };
shift;
}
# That's it for the data collection, now run the tests
view all matches for this distribution
view release on metacpan or search on metacpan
Cloudinary-0.16/Cloudinary-0.16/lib/Cloudinary.pm view on Meta::CPAN
package Cloudinary;
use Mojo::Base -base;
use File::Basename;
use Mojo::UserAgent;
use Mojo::Util qw(sha1_sum url_escape);
use Scalar::Util 'weaken';
our $VERSION = '0.16';
our (%SHORTER, %LONGER);
my @SIGNATURE_KEYS = qw(callback eager format public_id tags timestamp transformation type);
Cloudinary-0.16/Cloudinary-0.16/lib/Cloudinary.pm view on Meta::CPAN
my $headers = {'Content-Type' => 'multipart/form-data'};
$post->{api_key} = $self->api_key;
$post->{signature} = $self->_api_sign_request($post);
Scalar::Util::weaken($self);
my $tx = $self->_ua->post(
$url, $headers,
form => $post,
$cb ? sub { $self->$cb($_[1]->res->json || {error => $_[1]->error || 'Unknown error'}) } : (),
);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Clustericious/App.pm view on Meta::CPAN
use MojoX::Log::Log4perl;
use Mojo::UserAgent;
use Data::Dumper;
use Clustericious::Log;
use Mojo::URL;
use Scalar::Util qw( weaken );
use Mojo::Base 'Mojolicious';
use File::Glob qw( bsd_glob );
use File::Path qw( mkpath );
use Carp qw( croak carp );
use Clustericious;
lib/Clustericious/App.pm view on Meta::CPAN
our $VERSION = '1.29'; # VERSION
has commands => sub {
my $commands = Clustericious::Commands->new(app => shift);
weaken $commands->{app};
return $commands;
};
sub startup {
view all matches for this distribution
view release on metacpan or search on metacpan
examples/helloworld/app/lib/Dwarf.pm view on Meta::CPAN
use Data::Dumper;
use File::Basename 'dirname';
use File::Spec::Functions 'catfile';
use Module::Find;
use Router::Simple;
use Scalar::Util qw/weaken/;
our $VERSION = '1.83';
use constant {
BEFORE_DISPATCH => 'before_dispatch',
examples/helloworld/app/lib/Dwarf.pm view on Meta::CPAN
$self->{config} ||= do {
my $class = join '::', $self->namespace, 'Config';
$class .= '::' . ucfirst $self->config_name if $self->can('config_name');
load_class($class);
my $config = $class->new(context => $self);
weaken($config->{context});
$config;
};
}
sub _build_error {
examples/helloworld/app/lib/Dwarf.pm view on Meta::CPAN
return $self->handle_not_found unless $controller;
Dwarf::Util::load_class($controller);
$self->{handler_class} = $controller;
$self->{handler} = $controller->new(context => $self);
weaken($self->{handler}->{context});
my $method = $self->find_method;
return $self->not_found unless $method;
$self->handler->init($self);
examples/helloworld/app/lib/Dwarf.pm view on Meta::CPAN
$package = $prefix . '::' . $package;
}
load_class($package);
my $module = $package->new(context => $self, @_);
weaken $module->{context};
$module->init($self);
return $module;
}
sub call_before_trigger {
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
src/ppport.h view on Meta::CPAN
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Code/TidyAll/Plugin.pm view on Meta::CPAN
use warnings;
use Code::TidyAll::Util::Zglob qw(zglobs_to_regex);
use File::Which qw(which);
use IPC::Run3 qw(run3);
use Scalar::Util qw(weaken);
use Specio::Declare;
use Specio::Library::Builtins;
use Specio::Library::Numeric;
use Specio::Library::String;
use Text::Diff 1.44 qw(diff);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CodeGen/Cpppp/Template.pm view on Meta::CPAN
}
sub _gen_BUILD_method($class, $cpppp_ver, $perl, $src_filename, $src_lineno) {
return
"sub ${class}::BUILD(\$self, \$constructor_parameters=undef) {",
" Scalar::Util::weaken(\$self);",
# Inject all the lexical functions that need to be in scope
$class->_gen_perl_scope_functions($cpppp_ver),
qq{# line $src_lineno "$src_filename"},
$perl,
"}",
lib/CodeGen/Cpppp/Template.pm view on Meta::CPAN
indent => $parse->{indent},
output => CodeGen::Cpppp::Output->new,
current_output_section => 'private',
%attrs,
}, $class;
Scalar::Util::weaken($self->{context})
if $self->{context};
$self->BUILD(\%attrs);
$self->flush;
}
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
" unless \$#_ > 0 or defined \$_[0]->{%s};\n",
weak_init =>
" return do {\n" .
" \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" .
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" .
" \$_[0]->{%s};\n" .
" } unless \$#_ > 0 or defined \$_[0]->{%s};\n",
return_if_get =>
" return \$_[0]->{%s} unless \$#_ > 0;\n",
set =>
" \$_[0]->{%s} = \$_[1];\n",
weaken =>
" Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n",
sub_end =>
" return \$_[0]->{%s};\n}\n",
);
sub field {
inc/Spiffy.pm view on Meta::CPAN
local *paired_arguments = sub { (qw(-package -init)) };
Spiffy->parse_arguments(@_);
};
my ($field, $default) = @values;
$package = $args->{-package} if defined $args->{-package};
die "Cannot have a default for a weakened field ($field)"
if defined $default && $args->{-weak};
return if defined &{"${package}::$field"};
require Scalar::Util if $args->{-weak};
my $default_string =
( ref($default) eq 'ARRAY' and not @$default )
inc/Spiffy.pm view on Meta::CPAN
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
if defined $default;
$code .= sprintf $code{return_if_get}, $field;
$code .= sprintf $code{set}, $field;
$code .= sprintf $code{weaken}, $field, $field
if $args->{-weak};
$code .= sprintf $code{sub_end}, $field;
my $sub = eval $code;
die $@ if $@;
view all matches for this distribution
view release on metacpan or search on metacpan
SvROK_off|5.003007|5.003007|
SvROK_on|5.003007|5.003007|
SvRV|5.003007|5.003007|
SvRV_const|5.010001||Viu
SvRV_set|5.009003|5.003007|p
sv_rvunweaken|5.027004|5.027004|
sv_rvweaken|5.006000|5.006000|
SvRVx|5.003007||Viu
SvRX|5.009005|5.003007|p
SvRXOK|5.009005|5.003007|p
SV_SAVED_COPY|5.009005||Viu
SvSCREAM|5.003007||Viu
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
src/ppport.h view on Meta::CPAN
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_resetpvn|||
sv_reset|||
sv_rvweaken||5.006000|
sv_sethek|||
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
view all matches for this distribution
view release on metacpan or search on metacpan
sv_ref||5.015004|
sv_replace|||
sv_report_used|||
sv_resetpvn|||
sv_reset|||
sv_rvweaken||5.006000|
sv_sethek|||
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
view all matches for this distribution
view release on metacpan or search on metacpan
t/Test/More.pm view on Meta::CPAN
use Test::More tests => $Num_Tests;
There are rare cases when you will not know beforehand how many tests
your script is going to run. In this case, you can declare that you
have no plan. (Try to avoid using this as it weakens your test.)
use Test::More qw(no_plan);
B<NOTE>: using no_plan requires a Test::Harness upgrade else it will
think everything has failed. See L<BUGS>)
view all matches for this distribution
view release on metacpan or search on metacpan
t/Test/More.pm view on Meta::CPAN
use Test::More tests => $Num_Tests;
There are rare cases when you will not know beforehand how many tests
your script is going to run. In this case, you can declare that you
have no plan. (Try to avoid using this as it weakens your test.)
use Test::More qw(no_plan);
B<NOTE>: using no_plan requires a Test::Harness upgrade else it will
think everything has failed. See L<BUGS>)
view all matches for this distribution
view release on metacpan or search on metacpan
t/Test/More.pm view on Meta::CPAN
use Test::More tests => $Num_Tests;
There are rare cases when you will not know beforehand how many tests
your script is going to run. In this case, you can declare that you
have no plan. (Try to avoid using this as it weakens your test.)
use Test::More qw(no_plan);
B<NOTE>: using no_plan requires a Test::Harness upgrade else it will
think everything has failed. See L<BUGS>)
view all matches for this distribution
view release on metacpan or search on metacpan
SvROK_off|5.003007|5.003007|
SvROK_on|5.003007|5.003007|
SvRV|5.003007|5.003007|
SvRV_const|5.010001||Viu
SvRV_set|5.009003|5.003007|p
sv_rvunweaken|5.027004|5.027004|
sv_rvweaken|5.006000|5.006000|
SvRVx|5.003007||Viu
SvRX|5.009005|5.003007|p
SvRXOK|5.009005|5.003007|p
SV_SAVED_COPY|5.009005||Viu
SvSCREAM|5.003007||Viu
view all matches for this distribution
view release on metacpan or search on metacpan
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_resetpvn|||
sv_reset|||
sv_rvweaken||5.006000|
sv_sethek|||
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
view all matches for this distribution
view release on metacpan or search on metacpan
SvROK|5.003007|5.003007|
SvROK_off|5.003007|5.003007|
SvROK_on|5.003007|5.003007|
SvRV|5.003007|5.003007|
SvRV_set|5.009003|5.003007|p
sv_rvunweaken|5.027004|5.027004|
sv_rvweaken|5.006000|5.006000|
SvRX|5.009005|5.003007|p
SvRXOK|5.009005|5.003007|p
sv_sethek|5.015004||cViu
sv_setiv|5.003007|5.003007|
sv_setiv_mg|5.004005|5.003007|p
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
sv_ref||5.015004|
sv_replace|||
sv_report_used|||
sv_resetpvn|||
sv_reset|||
sv_rvweaken||5.006000|
sv_sethek|||
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Conduit/Client.pm view on Meta::CPAN
fill => sub () { Future::IO->sysread( $socket, 8192 ); },
);
}
field $server :param :inheritable;
ADJUST { builtin::weaken( $server ); }
async method read_request ()
{
defined( my $header = await $readbuf->read_until( qr/\x0D\x0A\x0D\x0A/ ) )
or return undef;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Config/ApacheExtended.pm view on Meta::CPAN
package Config::ApacheExtended;
use Parse::RecDescent;
use Config::ApacheExtended::Grammar;
use IO::File;
use Scalar::Util qw(weaken);
use Text::Balanced qw(extract_variable);
use File::Spec::Functions qw(splitpath catpath abs2rel rel2abs file_name_is_absolute);
use Carp qw(croak cluck);
use strict;
BEGIN {
lib/Config/ApacheExtended.pm view on Meta::CPAN
$block->{_data} = {%$data};
if ( $self->{_inherit_vals} )
{
my $parent = $self;
weaken($parent);
$block->{_parent} = $parent;
}
$block->_substituteValues() if $self->{_expand_vars};
return $block;
view all matches for this distribution