about summary refs log blame commit diff
path: root/perl/lib/Nix/Utils.pm
blob: 1e7e0b5afb2f3f8c70d2bf5bd388bf62bc19b782 (plain) (tree)
1
2
3
4
5
6
7
8







                                                                                          










                             
package Nix::Utils;

$urlRE = "(?: [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*]+ )";

sub checkURL {
    my ($url) = @_;
    die "invalid URL ‘$url\n" unless $url =~ /^ $urlRE $ /x;
}

sub uniq {
    my %seen;
    my @res;
    foreach my $name (@_) {
        next if $seen{$name};
        $seen{$name} = 1;
        push @res, $name;
    }
    return @res;
}