File: RandomList.pm

package info (click to toggle)
libtest-mockrandom-perl 1.01-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 256 kB
  • sloc: perl: 326; makefile: 2
file content (13 lines) | stat: -rw-r--r-- 196 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
package RandomList;

sub new {
    my ( $class, @items ) = @_;
    return bless( \@items, $class );
}

sub random {
    my ($self) = @_;
    return @$self ? $self->[ rand(@$self) ] : undef;
}

1;