/[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.3 - (show annotations)
Wed Jan 22 17:58:48 2003 UTC (21 years, 5 months ago) by root
Branch: MAIN
Changes since 1.2: +10 -1 lines
sub get_chomped

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

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