testsuite: provide cp() if File::Copy is too old.
[exim.git] / test / lib / Exim / Utils.pm
1 package Exim::Utils;
2 use v5.10.1;
3 use strict;
4 use warnings;
5 use File::Copy;
6 use parent 'Exporter';
7 our @EXPORT_OK = qw(uniq numerically cp);
8
9
10 sub uniq {
11     my %uniq = map { $_, undef } @_;
12     return keys %uniq;
13 }
14
15 sub numerically { $::a <=> $::b }
16
17 sub cp {
18     if ($File::Copy::VERSION >= 2.15) { # since Perl 5.11 we should have >= 2.15
19         return File::Copy::cp(@_);
20     }
21     copy(@_) or return undef;
22     my ($src, $dst) = @_;
23     my @st = stat $src or return undef;
24     chmod($st[2]&07777, $dst);
25 }
26
27 1;