HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //proc/self/root/usr/local/share/perl5/Graph/Easy/Util.pm
package Graph::Easy::Util;

use strict;
use warnings;

use base 'Exporter';

our @EXPORT_OK = (qw(first_kv ord_values));

use List::Util qw(minstr);

=head1 FUNCTIONS

=head2 first_kv($hash_ref)

The first key value pair from a hash reference - lexicographically.

=cut

sub first_kv
{
    my $href = shift;

    my $n = minstr( keys(%$href) );
    my $v = $href->{$n};

    return ($n, $v);
}

=head2 ord_values($hash_ref)

The values of the hash ordered by a lexicographical keyname.

=cut

sub ord_values
{
    my $href = shift;

    if ((!defined $href) || (! %$href))
    {
        return (wantarray ? () : 0);
    }
    else
    {
        return (wantarray ? @{$href}{sort keys( %$href )} : scalar(keys(%$href)));
    }
}

1;