-
Notifications
You must be signed in to change notification settings - Fork 8
/
Tools.pm
56 lines (42 loc) · 881 Bytes
/
Tools.pm
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
48
49
50
51
52
53
54
55
56
package Tools;
#use feature ':5.10';
use strict;
use warnings;
use Data::Dumper;
use Carp qw( croak );
use Exporter;
use base 'Exporter';
our @EXPORT_OK = qw(
normalize_planet
usage
debug
verbose
output
);
our %EXPORT_TAGS = (
'all' => \@EXPORT_OK,
'messages' => [qw(usage debug verbose output)],
);
our $VERSION = '0.01';
sub normalize_planet {
my ($planet_name) = @_;
$planet_name =~ s/\W//g;
$planet_name = lc($planet_name);
return $planet_name;
}
sub usage {
die $main::usage;
}
sub debug {
return unless ( grep { $main::opts{$_} } qw( debug d ) );
output(' ==== ',@_);
}
sub verbose {
return unless ( grep { $main::opts{$_} } qw( verbose v debug ) );
output(' -- ',@_);
}
sub output {
return if ( grep { $main::opts{$_} } qw( quiet q ) );
print scalar(localtime),': ',@_,"\n";
}
1;