view release on metacpan or search on metacpan
lib/DBIx/TransactionManager/Distributed.pm view on Meta::CPAN
release_dbh(category2 => $dbh2);
release_dbh(category3 => $dbh3);
=cut
use Scalar::Util qw(weaken refaddr);
use List::UtilsBy qw(extract_by);
our @EXPORT_OK = qw(register_dbh release_dbh dbh_is_registered txn register_cached_dbh);
# List of all retained handles by category. Since we don't expect to update
lib/DBIx/TransactionManager/Distributed.pm view on Meta::CPAN
if (dbh_is_registered($category, $dbh)) {
warn "already registered this database handle at " . $DBH_SOURCE{$category}{$addr};
return;
}
push @{$DBH{$category}}, $dbh;
weaken($DBH{$category}[-1]);
# filename:line (package::sub)
$DBH_SOURCE{$category}{$addr} = sprintf "%s:%d (%s::%s)", (caller 1)[1, 2, 0, 3];
# We may be connecting partway through a transaction - if so, we want to join this handle onto the list of
# active transactions
$dbh->begin_work if $IN_TRANSACTION && $dbh->{AutoCommit};
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/DBM/Deep.pm view on Meta::CPAN
if( $self->{engine}->{external_refs}
and my $sector = $self->{engine}->load_sector( $self->{base_offset} )
) {
$sector->increment_refcount;
Scalar::Util::weaken( my $feeble_ref = $self );
$obj_cache{ $self } = \$feeble_ref;
# Make sure this cache is not a memory hog
if(!HAVE_HUFH) {
for(keys %obj_cache) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBR/ResultSet.pm view on Meta::CPAN
use strict;
use base 'DBR::Common';
use DBR::Misc::Dummy;
use Carp;
use Scalar::Util 'weaken';
use constant ({
f_next => 0,
f_state => 1,
f_rowcache => 2,
f_query => 3,
lib/DBR/ResultSet.pm view on Meta::CPAN
}
# IMPORTANT NOTE: circular reference hazard
weaken ($self); # Weaken the refcount
my $endsub = sub {
defined($self) or return DUMMY; # technically this could be out of scope because it's a weak ref
$self->[f_count] ||= $sth->rows || 0;
lib/DBR/ResultSet.pm view on Meta::CPAN
my $commonref;
my $getchunk = sub {
$rows = $sth->fetchall_arrayref(undef,1000) || return undef; # if cache is empty, fetch more
$commonref = [ @$rows ];
map {weaken $_} @$commonref;
$buddy = [ $commonref, $record ]; # buddy ref must contain the record object just to keep it in scope.
return shift @$rows;
};
# use a closure to reduce hash lookups
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
inc/Pegex/Parser.pm view on Meta::CPAN
receiver => $self->{receiver},
);
$optimizer->optimize_grammar($start_rule_ref);
# Add circular ref and weaken it.
$self->{receiver}{parser} = $self;
Scalar::Util::weaken($self->{receiver}{parser});
if ($self->{receiver}->can("initial")) {
$self->{rule} = $start_rule_ref;
$self->{parent} = {};
$self->{receiver}->initial();
view all matches for this distribution
view release on metacpan or search on metacpan
dev/xml-test.pl view on Meta::CPAN
use strict;
use warnings;
use XML::SAX;
use XML::SAX::ParserFactory;
use Scalar::Util qw(weaken);
use Test::More tests => 11;
use Data::Dumper;
my $mode = shift;
dev/xml-test.pl view on Meta::CPAN
} else {
ok(1);
}
$p->parse_string($fulldoc);
$weakcheck = \$p;
weaken($weakcheck);
$weakcheck_h = \$handler;
weaken($weakcheck_h);
like($full_events, qr/\{aa\}name/, "parser supports namespaces properly");
like($full_events, qr/\{bb\}name/, "parser supports namespaces properly");
like($full_events, qr/\{\}global/, "parser supports namespaces properly");
}
dev/xml-test.pl view on Meta::CPAN
my $handler = EventRecorder->new(\$streamed_events);
my $p = $factory->parser(Handler => $handler);
$p->$iter_method($first_chunk);
$p->$iter_method($second_chunk);
$weakcheck = \$p;
weaken($weakcheck);
}
is($weakcheck, undef, "parser was destroyed");
use Text::Diff;
dev/xml-test.pl view on Meta::CPAN
use XML::LibXML;
use XML::SAX::Base;
use base qw(XML::SAX::Base);
use Carp;
use Data::Dumper;
use Scalar::Util qw(weaken);
sub new {
my ($class, @params) = @_;
my $inst = $class->SUPER::new(@params);
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
easyxs/ppport.h view on Meta::CPAN
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
test_data/big.log view on Meta::CPAN
2010-07-13 12:18:58 status half-installed libwww-perl 5.813-1
2010-07-13 12:18:58 status half-installed libwww-perl 5.813-1
2010-07-13 12:18:59 status half-installed libwww-perl 5.813-1
2010-07-13 12:18:59 status unpacked libwww-perl 5.836-1
2010-07-13 12:18:59 status unpacked libwww-perl 5.836-1
2010-07-13 12:18:59 install libtask-weaken-perl <keine> 1.03-1
2010-07-13 12:18:59 status half-installed libtask-weaken-perl 1.03-1
2010-07-13 12:18:59 status half-installed libtask-weaken-perl 1.03-1
2010-07-13 12:18:59 status unpacked libtask-weaken-perl 1.03-1
2010-07-13 12:18:59 status unpacked libtask-weaken-perl 1.03-1
2010-07-13 12:18:59 upgrade libsoap-lite-perl 0.710.08-1 0.712-1
2010-07-13 12:18:59 status half-configured libsoap-lite-perl 0.710.08-1
2010-07-13 12:18:59 status unpacked libsoap-lite-perl 0.710.08-1
2010-07-13 12:18:59 status half-installed libsoap-lite-perl 0.710.08-1
2010-07-13 12:19:00 status half-installed libsoap-lite-perl 0.710.08-1
test_data/big.log view on Meta::CPAN
2010-07-13 12:23:50 status installed libslv2-9 0.6.6-4
2010-07-13 12:23:50 configure libwww-perl 5.836-1 5.836-1
2010-07-13 12:23:50 status unpacked libwww-perl 5.836-1
2010-07-13 12:23:50 status half-configured libwww-perl 5.836-1
2010-07-13 12:23:50 status installed libwww-perl 5.836-1
2010-07-13 12:23:50 configure libtask-weaken-perl 1.03-1 1.03-1
2010-07-13 12:23:50 status unpacked libtask-weaken-perl 1.03-1
2010-07-13 12:23:50 status half-configured libtask-weaken-perl 1.03-1
2010-07-13 12:23:50 status installed libtask-weaken-perl 1.03-1
2010-07-13 12:23:50 configure libsoap-lite-perl 0.712-1 0.712-1
2010-07-13 12:23:50 status unpacked libsoap-lite-perl 0.712-1
2010-07-13 12:23:50 status half-configured libsoap-lite-perl 0.712-1
2010-07-13 12:23:50 status installed libsoap-lite-perl 0.712-1
2010-07-13 12:23:50 configure libsoup-gnome2.4-1 2.30.2-1 2.30.2-1
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DR/Tarantool/AEConnection.pm view on Meta::CPAN
$self->_check_reconnect;
}
sub _check_reconnect {
Scalar::Util::weaken(my $self = shift);
return if $self->state eq 'connected';
return if $self->state eq 'connecting';
return if $self->{guard}{rc};
return unless $self->reconnect_period;
lib/DR/Tarantool/AEConnection.pm view on Meta::CPAN
$self->connect;
};
}
sub connect {
Scalar::Util::weaken(my $self = shift);
return if $self->state eq 'connected' or $self->state eq 'connecting';
$self->{state} = 'connecting';
$self->{error} = undef;
lib/DR/Tarantool/AEConnection.pm view on Meta::CPAN
$self;
}
sub disconnect {
Scalar::Util::weaken(my $self = shift);
return if $self->state eq 'disconnect' or $self->state eq 'init';
$self->{guard} = {};
$self->{error} = 'Disconnected';
$self->{errno} = 'SUCCESS';
lib/DR/Tarantool/AEConnection.pm view on Meta::CPAN
$self->{on}{disconnect}($self);
}
sub push_write {
Scalar::Util::weaken(my $self = shift);
my ($str) = @_;
$self->{wbuf} .= $str;
return unless $self->state eq 'connected';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DSP/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
CAB/Analyzer.pm view on Meta::CPAN
use DTA::CAB::Persistent;
use DTA::CAB::Logger;
use DTA::CAB::Datum ':all';
use DTA::CAB::Utils ':minmax', ':files', ':time';
use File::Basename qw(basename dirname);
use Scalar::Util qw(weaken);
use Exporter;
use Carp;
use strict;
##==============================================================================
CAB/Analyzer.pm view on Meta::CPAN
## + default implementation calls $anl->getAnalyze"${which}"Closure() if
## available, otherwise croak()s
sub getAnalyzeClosure {
my ($anl,$which) = @_;
my $getsub = $anl->can("getAnalyze${which}Closure");
weaken($anl);
return $getsub->($anl) if ($getsub);
$anl->logconfess("getAnalyzeClosure('$which'): no getAnalyze${which}Closure() method defined!");
}
##------------------------------------------------------------------------
CAB/Analyzer.pm view on Meta::CPAN
my $do_cache = !exists($opts{cache}) || $opts{cache};
my $sub = ($do_cache ? $CLOSURE_CACHE{$anl}{$code} : undef);
my $cached = $sub ? 1 : 0;
weaken($anl);
$sub ||= eval $code;
$anl->logcluck("accessClosure(): could not compile closure {$code}: $@") if (!$sub);
$CLOSURE_CACHE{$anl}{$code} = $sub if ($do_cache && !$cached);
return $sub;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DTL/Fast/Entity.pm view on Meta::CPAN
use strict;
use utf8;
use warnings FATAL => 'all';
# prototype for template entity. Handling current line and current template references
use Scalar::Util qw(weaken);
use Carp qw(confess);
sub new
{
my ( $proto, %kwargs ) = @_;
lib/DTL/Fast/Entity.pm view on Meta::CPAN
{
my ($self) = @_;
$self->{_template} = $DTL::Fast::Template::CURRENT_TEMPLATE;
$self->{_template_line} = $DTL::Fast::Template::CURRENT_TEMPLATE_LINE;
weaken $self->{_template};
return $self;
}
sub get_parse_error
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/DWH_File/Cache.pm view on Meta::CPAN
bless $self, $class;
return $self;
}
sub encache {
# weaken if available
$_[ 0 ]->{ $_[ 1 ]->cache_key } = $_[ 1 ];
$_[ 1 ]->cache_up;
}
sub decache {
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
lib/Dancer/Logger/File/PerRequest.pm view on Meta::CPAN
return $file . '-' . $$ . '-' . $request_id . '.log';
};
$self->{logfile_callback} = $logfile_callback;
# per request
Scalar::Util::weaken $self;
my $on_end = sub {
return unless $self->{fh};
Dancer::Factory::Hook->execute_hooks('before_file_per_request_close', $self->{fh}, $self->{logfile});
close($self->{fh}); # close
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Mail/Email/IMAP.pm view on Meta::CPAN
package Mail::Email::IMAP;
use strict;
use MIME::WordDecoder;
use MIME::Base64;
use MIME::QuotedPrint;
use Scalar::Util qw(weaken);
use Encode qw(decode);
use Text::Markdown ();
use HTTP::Date qw( time2isoz );
use Time::Piece;
#use 5.016; # for fc
lib/Mail/Email/IMAP.pm view on Meta::CPAN
} => $class;
};
sub from_imap_client {
my ($package, $conn, $uid, %info) = @_;
#weaken $conn;
my $dt = $conn->date( $uid );
my $timestamp;
if( $dt ) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/Auth/Extensible.pm view on Meta::CPAN
sub BUILD {
my $plugin = shift;
my $app = $plugin->app;
Scalar::Util::weaken( my $weak_plugin = $plugin );
warn "No Auth::Extensible realms configured with which to authenticate user"
unless $plugin->realm_count;
# Force all providers to load whilst we have access to the full dsl.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/BrowserDetect.pm view on Meta::CPAN
#ABSTRACT: Provides an easy to have info of the browser.
sub BUILD {
my $plugin = shift;
# Create a weakened plugin that we can close over to avoid leaking.
Scalar::Util::weaken( my $weak_plugin = $plugin );
$plugin->app->add_hook(
Dancer2::Core::Hook->new(
name => 'before_template',
code => sub {
my $tokens = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/Interchange6.pm view on Meta::CPAN
use warnings;
use Dancer2::Plugin;
use Dancer2::Plugin::Interchange6::Business::OnlinePayment;
use Module::Runtime 'use_module';
use Scalar::Util 'weaken';
=head1 NAME
Dancer2::Plugin::Interchange6 - Interchange6 Shop Plugin for Dancer2
lib/Dancer2/Plugin/Interchange6.pm view on Meta::CPAN
'shop_state',
'shop_user';
sub BUILD {
my $plugin = shift;
weaken ( my $weak_plugin = $plugin );
$plugin->app->add_hook(
Dancer2::Core::Hook->new(
name => 'before',
code => sub {
# D2PAE::Provider::DBIC returns logged_in_user as hashref
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/ParamTypes.pm view on Meta::CPAN
'builder' => '_build_type_actions',
);
sub _build_type_actions {
my $self = shift;
Scalar::Util::weaken( my $plugin = $self );
return {
'error' => sub {
my ( $self, $details ) = @_;
my ( $type, $name ) = @{$details}{qw<type name>};
lib/Dancer2/Plugin/ParamTypes.pm view on Meta::CPAN
'action' => $action,
};
}
# Couldn't prove yet that this is required, but it makes sense to me
Scalar::Util::weaken( my $plugin = $self );
return sub {
my @route_args = @_;
# Hash::MultiValue has "each" method which we could use to
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Core/App.pm view on Meta::CPAN
or croak "Cannot load session engine '$value': illegal module name";
my $engine_options =
$self->_get_config_for_engine( session => $value, $config );
Scalar::Util::weaken( my $weak_self = $self );
# Note that engine options will replace the default session_dir (if provided).
return $self->_factory->create(
session => $value,
session_dir => path( $self->config->{appdir}, 'sessions' ),
lib/Dancer2/Core/App.pm view on Meta::CPAN
layout => $config->{layout},
layout_dir => ( $config->{layout_dir} || 'layouts' ),
views => $config->{views},
};
Scalar::Util::weaken( my $weak_self = $self );
return $self->_factory->create(
template => $value,
%{$engine_attrs},
postponed_hooks => $self->postponed_hooks,
lib/Dancer2/Core/App.pm view on Meta::CPAN
is_ref($value) and return $value;
my $engine_options =
$self->_get_config_for_engine( serializer => $value, $config );
Scalar::Util::weaken( my $weak_self = $self );
return $self->_factory->create(
serializer => $value,
config => $engine_options,
postponed_hooks => $self->postponed_hooks,
lib/Dancer2/Core/App.pm view on Meta::CPAN
# typically this is passed in as an optimization within the
# dispatch loop but may be called elsewhere
$defined_engines ||= $self->defined_engines;
# populate request in app and all engines
$self->_set_request($request);
Scalar::Util::weaken( my $weak_request = $request );
$_->set_request( $weak_request ) for @{$defined_engines};
}
has response => (
is => 'ro',
lib/Dancer2/Core/App.pm view on Meta::CPAN
my $self = shift;
# Hook to flush the session at the end of the request,
# this way, we're sure we flush only once per request
#
# Note: we create a weakened copy $self
# before closing over the weakened copy
# to avoid circular memory refs.
Scalar::Util::weaken(my $app = $self);
$self->add_hook(
Dancer2::Core::Hook->new(
name => 'core.app.after_request',
code => sub {
lib/Dancer2/Core/App.pm view on Meta::CPAN
return $responder->(
[ $res->status, $res->headers_to_array, $fh ]
);
};
Scalar::Util::weaken( my $weak_self = $self );
$response = Dancer2::Core::Response::Delayed->new(
error_cb => sub { $weak_self->logger_engine->log( warning => @_ ) },
cb => $cb,
request => $Dancer2::Core::Route::REQUEST,
lib/Dancer2/Core/App.pm view on Meta::CPAN
my ($self) = @_;
for my $position ( $self->supported_hooks ) {
my $compiled_hooks = [];
for my $hook ( @{ $self->hooks->{$position} } ) {
Scalar::Util::weaken( my $app = $self );
my $compiled = sub {
# don't run the filter if halt has been used
$Dancer2::Core::Route::RESPONSE &&
$Dancer2::Core::Route::RESPONSE->is_halted
and return;
lib/Dancer2/Core/App.pm view on Meta::CPAN
1;
};
# Catch bad content causing deserialization to fail when building the request
if ( ! $request_built_successfully ) {
my $err = $@;
Scalar::Util::weaken(my $app = $self);
return Dancer2::Core::Error->new(
app => $app,
message => $err,
status => 400, # 400 Bad request (dont send again), rather than 500
)->throw;
lib/Dancer2/Core/App.pm view on Meta::CPAN
return $response;
}
sub build_request {
my ( $self, $env ) = @_;
Scalar::Util::weaken( my $weak_self = $self );
# If we have an app, send the serialization engine
my $request = Dancer2::Core::Request->new(
env => $env,
is_behind_proxy => $self->settings->{'behind_proxy'} || 0,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DashProfiler/Core.pm view on Meta::CPAN
die @$ if $@ && $@ !~ /^Can't locate Hash\/Util/;
*lock_keys = sub { } if not defined &lock_keys;
}
# check for weaken support, used by ChildHandles
my $HAS_WEAKEN = eval {
require Scalar::Util;
# this will croak() if this Scalar::Util doesn't have a working weaken().
Scalar::Util::weaken( my $test = [] );
1;
};
*weaken = sub { croak "Can't weaken without Scalar::Util::weaken" }
unless $HAS_WEAKEN;
# On 2GHz OS X 10.5.2 laptop:
# sample_overhead_time = 0.000014s
lib/DashProfiler/Core.pm view on Meta::CPAN
$dbh->{Profile}->empty; # discard FETCH&STOREs etc due to connect()
for my $handles ($self->{dbi_handles_all}, $self->{dbi_handles_active}) {
# clean out any dead weakrefs
defined $handles->{$_} or delete $handles->{$_} for keys %$handles;
$handles->{$dbi_profile_name} = $dbh;
# weaken($handles->{$dbi_profile_name}) if $weakly; # not currently documented or used
}
return $dbh;
}
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
t/lib/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);
In some cases, you'll want to completely skip an entire testing script.
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