/[cvs]/nfo/perl/libs/org/netfrag/shortcuts.pm
ViewVC logotype

Contents of /nfo/perl/libs/org/netfrag/shortcuts.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Mon Jan 20 21:19:27 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
Changes since 1.1: +15 -5 lines
+ updated 'sub now': knows about option 'fs' now

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;

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed