/[cvs]/nfo/perl/scripts/shortcuts/rap.pl
ViewVC logotype

Diff of /nfo/perl/scripts/shortcuts/rap.pl

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

revision 1.1 by joko, Tue Feb 18 15:30:52 2003 UTC revision 1.4 by joko, Thu Mar 27 15:58:08 2003 UTC
# Line 4  Line 4 
4  ##  $Id$  ##  $Id$
5  ## -------------------------------------------------------------------------  ## -------------------------------------------------------------------------
6  ##  $Log$  ##  $Log$
7    ##  Revision 1.4  2003/03/27 15:58:08  joko
8    ##  enhancement: now can execute perl-programs via 'do' here
9    ##
10    ##  Revision 1.3  2003/02/20 21:39:49  joko
11    ##  - find_rules moved to Rap.pm
12    ##
13    ##  Revision 1.2  2003/02/18 19:09:07  jonen
14    ##  + cwd for linux bootstrap
15    ##
16  ##  Revision 1.1  2003/02/18 15:30:52  joko  ##  Revision 1.1  2003/02/18 15:30:52  joko
17  ##  + initial commit  ##  + initial commit
18  ##  ##
# Line 13  Line 22 
22  use strict;  use strict;
23  use warnings;  use warnings;
24    
25    
26    use File::Spec::Functions qw( splitpath splitdir catpath catdir );
27    
28    sub popdir {
29      my $path = shift;
30      my $popcount = shift;
31      (my $volume, my $directory, my $file) = splitpath( $path );
32      my @dir = splitdir($directory);
33      while ($popcount--) {
34        pop @dir;
35      }
36      #pop @dir;
37      
38      #my $base = catpath($volume, catdir(@dir));
39      my $base = join('/', @dir);
40      $base = $volume . $base if $volume;
41      
42      return $base;
43    }
44    
45    
46    
47  BEGIN {  BEGIN {
48    use FindBin qw($Bin);    use FindBin qw($Bin);
49    use lib "$Bin/../../libs";    #use lib "$Bin/../../libs";
50      my $libpath = popdir($Bin, 2) . '/libs';
51      #print "libpath: $libpath", "\n";
52      #exit;
53      my $evs = "use lib '$libpath';";
54      #print "evs: $evs", "\n";
55      eval($evs);
56      die($@) if $@;
57  }  }
58    
59    
# Line 23  BEGIN { Line 61  BEGIN {
61  use Data::Dumper;  use Data::Dumper;
62  use Data::Rap;  use Data::Rap;
63    
 sub find_rules {  
   return '../etc/rap.xml';  
 }  
64    
65  sub main {  sub main {
66    my $argString = shift;    my $argString = shift;
67    my $rulesfile = find_rules();    
68    my $rap = Data::Rap->new( filename => $rulesfile, target => $argString );    # check if target is a namespace-string (contains '::')
69    $rap->start();    # TODO: move this logic/code to inside Data::Rap!
70      if ($argString =~ s/::/\//g) {
71        my $res = do "$argString";
72        print $res, "\n" if $res;
73      } else {
74        my $rap = Data::Rap->new( target => $argString );
75        $rap->start();
76        #$rap->stop();
77      }
78  }  }
79    
80  my @args = @ARGV;  my @args = @ARGV;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

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