6 use List::Util qw'shuffle';
9 # find a group name, preferrable 'mail', but
10 # use some other random name if 'mail' isn't a valid group
15 croak "Need a group *name*, not a numeric group id."
18 return $group if getgrnam $group;
21 setgrent or die "setgrent: $!\n";
22 push @groups, $_ while defined($_ = getgrent);
24 return (shuffle @groups)[0];