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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Thu Mar 27 15:58:08 2003 UTC (21 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.3: +15 -4 lines
File MIME type: text/plain
enhancement: now can execute perl-programs via 'do' here

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

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