| 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 |
## Revision 1.3 2003/01/22 17:58:48 root |
| 9 |
## sub get_chomped |
## sub get_chomped |
| 10 |
## |
## |
| 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 |
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($_); |
|
|
} |
|
|
} |
|
|
|
|
|
sub get_chomped { |
|
|
my $str = shift; |
|
|
chomp($str); |
|
|
return $str; |
|
|
} |
|
|
|
|
| 33 |
1; |
1; |