2 |
## $Id$ |
## $Id$ |
3 |
## --------------------------------------------------------------------------- |
## --------------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.4 2003/02/09 16:31:00 joko |
6 |
|
## - moved code to ../../shortcuts.pm, this just inherits from that module now |
7 |
|
## |
8 |
|
## Revision 1.3 2003/01/22 17:58:48 root |
9 |
|
## sub get_chomped |
10 |
|
## |
11 |
## Revision 1.2 2003/01/20 21:19:27 joko |
## Revision 1.2 2003/01/20 21:19:27 joko |
12 |
## + updated 'sub now': knows about option 'fs' now |
## + updated 'sub now': knows about option 'fs' now |
13 |
## |
## |
23 |
use warnings; |
use warnings; |
24 |
|
|
25 |
require Exporter; |
require Exporter; |
26 |
our @ISA = qw( Exporter ); |
our @ISA = qw( shortcuts Exporter ); |
27 |
our @EXPORT_OK = qw( |
our @EXPORT_OK = qw( |
28 |
now today |
now today |
29 |
run_cmd run_cmds |
run_cmd run_cmds |
30 |
|
get_chomped |
31 |
); |
); |
32 |
|
|
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - main |
|
|
|
|
|
use Data::Dumper; |
|
|
use POSIX qw(strftime); |
|
|
|
|
|
# $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime; |
|
|
# see "perldoc -f localtime" |
|
|
|
|
|
sub now { |
|
|
my $options = shift; |
|
|
my $pattern = "%Y-%m-%d %H:%M:%S"; |
|
|
$pattern = "%Y-%m-%d_%H-%M-%S" if $options->{fs}; |
|
|
my $result = strftime($pattern, localtime); |
|
|
return $result; |
|
|
} |
|
|
|
|
|
sub today { |
|
|
return strftime("%Y-%m-%d", localtime); |
|
|
} |
|
|
|
|
|
sub run_cmd { |
|
|
my $cmd = shift; |
|
|
my $caption = shift; |
|
|
#$cmd = 'perl ' . $cmd; |
|
|
my $sep = "-" x 90; |
|
|
print $sep, "\n"; |
|
|
print " ", $cmd, "\n"; |
|
|
print " ", $caption, "\n" if $caption; |
|
|
print $sep, "\n"; |
|
|
system($cmd); |
|
|
#`$cmd`; |
|
|
print "ready.", "\n"; |
|
|
} |
|
|
|
|
|
sub run_cmds { |
|
|
foreach (@_) { |
|
|
run_cmd($_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
33 |
1; |
1; |