1 |
joko |
1.1 |
## --------------------------------------------------------------------------- |
2 |
|
|
## $Id$ |
3 |
|
|
## --------------------------------------------------------------------------- |
4 |
|
|
## $Log$ |
5 |
|
|
## --------------------------------------------------------------------------- |
6 |
|
|
|
7 |
|
|
|
8 |
|
|
package org::netfrag::shortcuts; |
9 |
|
|
|
10 |
|
|
use strict; |
11 |
|
|
use warnings; |
12 |
|
|
|
13 |
|
|
require Exporter; |
14 |
|
|
our @ISA = qw( Exporter ); |
15 |
|
|
our @EXPORT_OK = qw( |
16 |
|
|
now today |
17 |
|
|
run_cmd run_cmds |
18 |
|
|
); |
19 |
|
|
|
20 |
|
|
|
21 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - main |
22 |
|
|
|
23 |
|
|
use Data::Dumper; |
24 |
|
|
use POSIX qw(strftime); |
25 |
|
|
|
26 |
|
|
# $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime; |
27 |
|
|
# see "perldoc -f localtime" |
28 |
|
|
|
29 |
|
|
sub now { |
30 |
|
|
return strftime("%Y-%m-%d %H:%M:%S", localtime); |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
sub today { |
34 |
|
|
return strftime("%Y-%m-%d", localtime); |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
sub run_cmd { |
38 |
|
|
my $cmd = shift; |
39 |
|
|
$cmd = 'perl ' . $cmd; |
40 |
|
|
my $sep = "-" x 90; |
41 |
|
|
print $sep, "\n"; |
42 |
|
|
print " ", $cmd, "\n"; |
43 |
|
|
print $sep, "\n"; |
44 |
|
|
system($cmd); |
45 |
|
|
print "\n"; |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
sub run_cmds { |
49 |
|
|
foreach (@_) { |
50 |
|
|
run_cmd($_); |
51 |
|
|
} |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
|
55 |
|
|
1; |