Index | index by Group | index by Distribution | index by Vendor | index by creation date | index by Name | Mirrors | Help | Search |
Name: perl-Contextual-Return | Distribution: SUSE Linux Enterprise 15 SP5 |
Version: 0.004014 | Vendor: openSUSE |
Release: bp155.2.8 | Build date: Wed May 17 16:05:37 2023 |
Group: Development/Libraries/Perl | Build host: lamb16 |
Size: 163056 | Source RPM: perl-Contextual-Return-0.004014-bp155.2.8.src.rpm |
Packager: https://bugs.opensuse.org | |
Url: http://search.cpan.org/dist/Contextual-Return/ | |
Summary: Create context-sensitive return values |
Usually, when you need to create a subroutine that returns different values in different contexts (list, scalar, or void), you write something like: sub get_server_status { my ($server_ID) = @_; my %server_data = _ascertain_server_status($server_ID); if (wantarray()) { return @server_data{ qw(name uptime load users) }; } if (defined wantarray()) { return $server_data{load}; } if (!defined wantarray()) { carp 'Useless use of get_server_status() in void context'; return; } else { croak q{Bad context! No biscuit!}; } } That works okay, but the code could certainly be more readable. In its simplest usage, this module makes that code more readable by providing three subroutines--'LIST()', 'SCALAR()', 'VOID()'--that are true only when the current subroutine is called in the corresponding context: use Contextual::Return; sub get_server_status { my ($server_ID) = @_; my %server_data = _ascertain_server_status($server_ID); if (LIST) { return @server_data{ qw(name uptime load users) } } if (SCALAR) { return $server_data{load} } if (VOID) { print "$server_data{load}\n" } else { croak q{Bad context! No biscuit!} } }
Artistic-1.0 or GPL-1.0+
* Wed Apr 19 2017 coolo@suse.com - updated to 0.004014 see /usr/share/doc/packages/perl-Contextual-Return/Changes * Thu Apr 13 2017 coolo@suse.com - updated to 0.004012 see /usr/share/doc/packages/perl-Contextual-Return/Changes 0.004012 Thu Apr 13 01:06:09 2017 - Optimized previous patch for memory leak (thanks, Jay and Father C.) - Added missing test plan to t/fail.t * Sun Apr 09 2017 coolo@suse.com - updated to 0.004011 see /usr/share/doc/packages/perl-Contextual-Return/Changes 0.004011 Sat Apr 8 15:23:14 2017 - Patched memory leak from use of @DB::args (thanks, Jay!) * Fri Dec 02 2016 coolo@suse.com - updated to 0.004010 see /usr/share/doc/packages/perl-Contextual-Return/Changes 0.004010 Thu Dec 1 17:41:14 2016 - Spelling fix in POD (thanks, Salvatore) - Improved DUMP behaviour when passed a non-CRV argument (thanks, Mathew) * Wed Nov 23 2016 coolo@suse.com - remove Build.PL, it's obsolete * Fri Nov 18 2016 coolo@suse.com - updated to 0.004009 see /usr/share/doc/packages/perl-Contextual-Return/Changes 0.004009 Fri Nov 18 08:34:19 2016 - Improved behaviour of FREEZE (Thanks, Mathew!) - Improved output of DUMP * Mon Sep 14 2015 coolo@suse.com - updated to 0.004008 see /usr/share/doc/packages/perl-Contextual-Return/Changes 0.004008 Sat Sep 12 13:16:30 2015 - Promoted $VERSION variable to earlier in source to attempt to placate cpanminus (thanks, Karen!) - Added prototype to overridden caller() - Changed way caller() is overridden, hopefully will no longer clash with Sub::Uplevel * Mon Dec 17 2012 dvaleev@suse.com - update to 0.004007 - Further patch to failures.t - Added redefinition of Scalar::Util::blessed() to avoid nasty surprises (thanks Andrew!) - Added confess() and cluck() overrides and fixed caller() override to set @DB::args when appropriate - Further patch for t/confess.t (Thanks, David!) - Circumvented annoying undef-as-key warnings in Perl 5.17+ - Honour @CARP_NOT's when reporting context - Added BLESSED handler for better control over how blessed() lies - Upgraded reimplementation of blessed() to make more sense - reanable tests for ARM (fixed upstream) - fix ppc test failures - provide Build.PL to be able to use create_packlist=0 * Wed Aug 08 2012 dmueller@suse.com - also fails on native, fix build on ARM * Thu Jul 26 2012 dmueller@suse.com - workaround build failure under qemu user emulation
/usr/lib/perl5/vendor_perl/5.26.1/Contextual /usr/lib/perl5/vendor_perl/5.26.1/Contextual/Return /usr/lib/perl5/vendor_perl/5.26.1/Contextual/Return.pm /usr/lib/perl5/vendor_perl/5.26.1/Contextual/Return/Failure.pm /usr/lib/perl5/vendor_perl/5.26.1/x86_64-linux-thread-multi /usr/share/doc/packages/perl-Contextual-Return /usr/share/doc/packages/perl-Contextual-Return/Changes /usr/share/doc/packages/perl-Contextual-Return/README /usr/share/man/man3/Contextual::Return.3pm.gz /usr/share/man/man3/Contextual::Return::Failure.3pm.gz
Generated by rpm2html 1.8.1
Fabrice Bellet, Tue Jul 9 18:05:00 2024