1 |
## --------------------------------------------------------------------------- |
2 |
## $Id: shortcuts.pm,v 1.1 2003/01/19 02:08:08 joko Exp $ |
3 |
## --------------------------------------------------------------------------- |
4 |
## $Log: shortcuts.pm,v $ |
5 |
## Revision 1.1 2003/01/19 02:08:08 joko |
6 |
## + initial check-in |
7 |
## |
8 |
## --------------------------------------------------------------------------- |
9 |
|
10 |
|
11 |
package org::netfrag::shortcuts; |
12 |
|
13 |
use strict; |
14 |
use warnings; |
15 |
|
16 |
require Exporter; |
17 |
our @ISA = qw( Exporter ); |
18 |
our @EXPORT_OK = qw( |
19 |
now today |
20 |
run_cmd run_cmds |
21 |
); |
22 |
|
23 |
|
24 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - main |
25 |
|
26 |
use Data::Dumper; |
27 |
use POSIX qw(strftime); |
28 |
|
29 |
# $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime; |
30 |
# see "perldoc -f localtime" |
31 |
|
32 |
sub now { |
33 |
my $options = shift; |
34 |
my $pattern = "%Y-%m-%d %H:%M:%S"; |
35 |
$pattern = "%Y-%m-%d_%H-%M-%S" if $options->{fs}; |
36 |
my $result = strftime($pattern, localtime); |
37 |
return $result; |
38 |
} |
39 |
|
40 |
sub today { |
41 |
return strftime("%Y-%m-%d", localtime); |
42 |
} |
43 |
|
44 |
sub run_cmd { |
45 |
my $cmd = shift; |
46 |
my $caption = shift; |
47 |
#$cmd = 'perl ' . $cmd; |
48 |
my $sep = "-" x 90; |
49 |
print $sep, "\n"; |
50 |
print " ", $cmd, "\n"; |
51 |
print " ", $caption, "\n" if $caption; |
52 |
print $sep, "\n"; |
53 |
system($cmd); |
54 |
#`$cmd`; |
55 |
print "ready.", "\n"; |
56 |
} |
57 |
|
58 |
sub run_cmds { |
59 |
foreach (@_) { |
60 |
run_cmd($_); |
61 |
} |
62 |
} |
63 |
|
64 |
|
65 |
1; |