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

Diff of /nfo/perl/libs/libp.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by joko, Fri Nov 29 04:44:53 2002 UTC revision 1.12 by joko, Sun Dec 22 14:15:02 2002 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.12  2002/12/22 14:15:02  joko
7    #  + sub mkObject
8    #
9    #  Revision 1.11  2002/12/19 16:27:17  joko
10    #  +- renamed 'cmd' to 'run_cmd'
11    #
12    #  Revision 1.10  2002/12/19 01:05:35  joko
13    #  + sub today
14    #
15    #  Revision 1.9  2002/12/05 13:54:00  joko
16    #  + fix: let 'deep_copy' print its message out (instead of die)
17    #
18    #  Revision 1.8  2002/12/01 22:11:35  joko
19    #  + sub cmd
20    #  + sub run_cmds
21    #
22  #  Revision 1.7  2002/11/29 04:44:53  joko  #  Revision 1.7  2002/11/29 04:44:53  joko
23  #  - sub array_getRelations  #  - sub array_getRelations
24  #  + sub getNewPerlObjectByPkgName  #  + sub getNewPerlObjectByPkgName
# Line 40  our @EXPORT_OK = qw( Line 56  our @EXPORT_OK = qw(
56      md5 md5_hex md5_base64      md5 md5_hex md5_base64
57      ParseDate UnixDate      ParseDate UnixDate
58      strftime      strftime
     stripHtml stripSpaces stripNewLines toReal trim  
59      croak      croak
60    
61        stripHtml stripSpaces stripNewLines toReal trim
62      array_getDifference      array_getDifference
63      getDirList      getDirList
64      now      now today
65      deep_copy      deep_copy
66      getNewPerlObjectByPkgName      getNewPerlObjectByPkgName
67        run_cmd run_cmds
68        mkObject
69  );  );
70    
71  use Data::Dumper;  use Data::Dumper;
# Line 193  sub now { Line 212  sub now {
212    return strftime("%Y-%m-%d %H:%M:%S", localtime);    return strftime("%Y-%m-%d %H:%M:%S", localtime);
213  }  }
214    
215    sub today {
216      return strftime("%Y-%m-%d", localtime);
217    }
218    
219  # ACK's go to ...  # ACK's go to ...
220  sub deep_copy {  sub deep_copy {
221    my $this = shift;    my $this = shift;
# Line 204  sub deep_copy { Line 227  sub deep_copy {
227      +{map { $_ => deep_copy($this->{$_}) } keys %$this};      +{map { $_ => deep_copy($this->{$_}) } keys %$this};
228    } elsif (ref $this eq "CODE") {    } elsif (ref $this eq "CODE") {
229      $this;      $this;
230    } else { die "what type is $_?" }    #} else { die "deep_copy asks: what type is $this?" }
231      } else { print "deep_copy asks: what type is $this?", "\n"; }
232  }  }
233    
234  sub getNewPerlObjectByPkgName {  sub getNewPerlObjectByPkgName {
# Line 218  sub getNewPerlObjectByPkgName { Line 242  sub getNewPerlObjectByPkgName {
242    return $pkgname->new($args);    return $pkgname->new($args);
243  }  }
244    
245    sub mkObject {
246      my $pkgname = shift;
247      #my $args = shift;
248      #$logger->debug( __PACKAGE__ . "->getNewPerlObjectByPkgName( pkgname $pkgname args $args )" );
249      my $evstring = "use $pkgname;";
250      eval($evstring);
251      #$@ && $logger->error( __PACKAGE__ . ':' . __LINE__ . " Error in eval $evstring: " .  $@ );
252      $@ && print( __PACKAGE__ . ':' . __LINE__ . " Error in eval \"$evstring\": " .  $@ );
253      return $pkgname->new(@_);
254    }
255    
256    sub run_cmd {
257      my $cmd = shift;
258      $cmd = 'perl ' . $cmd;
259      my $sep = "-" x 90;
260      print $sep, "\n";
261      print "  ", $cmd, "\n";
262      print $sep, "\n";
263      system($cmd);
264      print "\n";
265    }
266    
267    sub run_cmds {
268      foreach (@_) {
269        run_cmd($_);
270      }
271    }
272    
273  1;  1;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.12

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