Packages / openSUSE Tumbleweed / Source / perl-Contextual-Return

Source Package: perl-Contextual-Return (0.4.14-1.5)

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

Package information

Homepage
[https://metacpan.org/release/Contextual-Return]
License
Artistic-1.0 OR GPL-1.0-or-later
Супровідник downstream-пакета
Невідомо: не зазначено в проіндексованому джерелі

The following binary packages are built from this source package:

Відомі вразливості

У відстежуваних джерелах немає відповідних повідомлень.

Остання синхронізація:

[Каталог CVE]

Джерела

  • Authoritative source; repository metadata signature verified

    Доказ підпису

    tumbleweed-oss-multiarch:4db10cdde3ad82c7e22be35753c9e164b4bdd30f92db4aee17a0d4c94c5f902f

    Repository-signature verification record
    Signed-object SHA-256
    4db10cdde3ad82c7e22be35753c9e164b4bdd30f92db4aee17a0d4c94c5f902f
    Signer fingerprint
    AD485664E901B867051AB15F35A2F86E29B700A4
    Keyring revision
    opensuse-project-signing-key.asc
    SHA-256 b5745739ebfb95b25b8e810f9bcb847fe750ccda598bd85f02f0e974599a6d7e
    Tool and policy
    gpgv (GnuPG) 2.4.9
    openfactory-software-catalog-signature-v1
    Verification time
    Sep 1, 2026
    Repository metadata hash linkage
    Result
    Recorded as verified; digest details unavailable