Contextual::Diag::Value - wrapping scalar value for diagnostics
use Contextual::Diag::Value; my $value = 'hello'; my $v = Contextual::Diag::Value->new($value, BOOL => sub { warn 'evaluated as BOOL'; return $_[0] }, ); if ($v) { } # => warn 'evaluated as BOOL';
Constructor for Contextual::Diag::Value:
Contextual::Diag::Value->new($_[0], BOOL => sub { $_[0] }, NUM => sub { $_[0] || 0 }, STR => sub { $_[0] || "" }, SCALARREF => sub { defined $_[0] ? $_[0] : \"" }, ARRAYREF => sub { defined $_[0] ? $_[0] : [] }, HASHREF => sub { defined $_[0] ? $_[0] : {} }, CODEREF => sub { defined $_[0] ? $_[0] : sub { } }, GLOBREF => sub { defined $_[0] ? $_[0] : do { no strict qw/refs/; my $package = __PACKAGE__; \*{$package} } }, OBJREF => sub { defined $_[0] ? $_[0] : bless {}, __PACKAGE__ }, );
Override can to hook OBJREF.
can
Override isa to hook OBJREF.
isa
Contextual::Return
Copyright (C) kfly8.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
kfly8 <kfly@cpan.org>
To install Contextual::Diag, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Contextual::Diag
CPAN shell
perl -MCPAN -e shell install Contextual::Diag
For more information on module installation, please visit the detailed CPAN module installation guide.