How to Install and Uninstall perl-Contextual-Return Package on openSUSE Leap
Last updated: November 26,2024
1. Install "perl-Contextual-Return" package
Learn how to install perl-Contextual-Return on openSUSE Leap
$
sudo zypper refresh
Copied
$
sudo zypper install
perl-Contextual-Return
Copied
2. Uninstall "perl-Contextual-Return" package
In this section, we are going to explain the necessary steps to uninstall perl-Contextual-Return on openSUSE Leap:
$
sudo zypper remove
perl-Contextual-Return
Copied
3. Information about the perl-Contextual-Return package on openSUSE Leap
Information for package perl-Contextual-Return:
-----------------------------------------------
Repository : Main Repository
Name : perl-Contextual-Return
Version : 0.004014-bp155.2.8
Arch : noarch
Vendor : openSUSE
Installed Size : 159.2 KiB
Installed : No
Status : not installed
Source package : perl-Contextual-Return-0.004014-bp155.2.8.src
Upstream URL : http://search.cpan.org/dist/Contextual-Return/
Summary : 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!} }
}
-----------------------------------------------
Repository : Main Repository
Name : perl-Contextual-Return
Version : 0.004014-bp155.2.8
Arch : noarch
Vendor : openSUSE
Installed Size : 159.2 KiB
Installed : No
Status : not installed
Source package : perl-Contextual-Return-0.004014-bp155.2.8.src
Upstream URL : http://search.cpan.org/dist/Contextual-Return/
Summary : 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!} }
}