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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Fri Feb 14 14:17:04 2003 UTC (21 years, 2 months ago) by joko
Branch: MAIN
Changes since 1.2: +5 -2 lines
- shortened seperator

1 ## ---------------------------------------------------------------------------
2 ## $Id: shortcuts.pm,v 1.2 2003/02/11 05:14:28 joko Exp $
3 ## ---------------------------------------------------------------------------
4 ## $Log: shortcuts.pm,v $
5 ## Revision 1.2 2003/02/11 05:14:28 joko
6 ## + refactored code from libp.pm
7 ##
8 ## Revision 1.1 2003/02/09 04:49:45 joko
9 ## + shortcuts now refactored to this file
10 ##
11 ## ---------------------------------------------------------------------------
12
13
14 package shortcuts;
15
16 use strict;
17 use warnings;
18
19 require Exporter;
20 our @ISA = qw( Exporter );
21 our @EXPORT_OK = qw(
22 strftime
23 now today
24 run_cmd run_cmds
25 get_chomped
26 bool2status
27 );
28
29
30 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - main
31
32 use Data::Dumper;
33 use POSIX qw(strftime);
34
35 # $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
36 # see "perldoc -f localtime"
37
38 sub now {
39 my $options = shift;
40 my $pattern = "%Y-%m-%d %H:%M:%S";
41 $pattern = "%Y-%m-%d_%H-%M-%S" if $options->{fs};
42 my $result = strftime($pattern, localtime);
43 return $result;
44 }
45
46 sub today {
47 return strftime("%Y-%m-%d", localtime);
48 }
49
50 sub run_cmd {
51 my $cmd = shift;
52 my $caption = shift;
53 #$cmd = 'perl ' . $cmd;
54 my $sep = "-" x 60;
55 print $sep, "\n";
56 print " ", $cmd, "\n";
57 print " ", $caption, "\n" if $caption;
58 print $sep, "\n";
59 system($cmd);
60 #`$cmd`;
61 print "ready.", "\n";
62 }
63
64 sub run_cmds {
65 foreach (@_) {
66 run_cmd($_);
67 }
68 }
69
70 sub get_chomped {
71 my $str = shift;
72 chomp($str);
73 return $str;
74 }
75
76 sub bool2status {
77 my $bool = shift;
78 return ($bool ? 'ok' : 'failed');
79 }
80
81 1;

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