File: Util.pm

package info (click to toggle)
libdbix-searchbuilder-perl 1.82-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 776 kB
  • sloc: perl: 10,608; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 881 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use strict;
use warnings;

package DBIx::SearchBuilder::Util;
use base 'Exporter';

our @EXPORT_OK = qw(
    sorted_values
);

=head1 NAME

DBIx::SearchBuilder::Util - Utility and convenience functions for DBIx::SearchBuilder

=head1 SYNOPSIS

    use DBIx::SearchBuilder::Util qw( sorted_values );  # or other function you want

=head1 EXPORTED FUNCTIONS

=head2 sorted_values

Takes a hash or hashref and returns the values sorted by their respective keys.

Equivalent to

    map { $hash{$_} } sort keys %hash

but far more convenient.

=cut

sub sorted_values {
    my $hash = @_ == 1 ? $_[0] : { @_ };
    return map { $hash->{$_} } sort keys %$hash;
}

=head1 LICENSE AND COPYRIGHT

Copyright (c) 2013 Best Practical Solutions, LLC.  All rights reserved.

This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

=cut

1;