Logoj0ke.net Open Build Service > Projects > server:monitoring > nagios-plugins-nwc-health > Binaries > nagios-plugins-nwc-health-8... > Dependencies
Sign Up | Log In

Dependency of nagios-plugins-nwc-health-8.0-1.1.src.rpm

Name: perl-Contextual-Return

Project: openSUSE_13.2

Repository: oss

Title: Create context-sensitive return values

Description:
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!} }
}

Version: 0.004007

Release: 6.1.3

Architecture: noarch

Size: 59.3 KB

Build Time: 2014-10-06 16:47:35 +0200 (over 9 years ago)

Provides

Symbol Required by
perl(Contextual::Return)
perl(Contextual::Return::Fa...
perl(Contextual::Return::Lv...
perl(Contextual::Return::Va...
perl(DB)
perl(DB) = 0.004007
perl-Contextual-Return = 0....

Requires

Symbol Provided by
perl(:MODULE_COMPAT_5.20.1) perl
perl(Want) perl-Want
perl(version) perl-base perl-version