--- nfo/perl/scripts/shortcuts/rap.pl 2003/02/18 15:30:52 1.1 +++ nfo/perl/scripts/shortcuts/rap.pl 2003/02/20 21:39:49 1.3 @@ -1,9 +1,15 @@ #!/usr/bin/perl ## ------------------------------------------------------------------------- -## $Id: rap.pl,v 1.1 2003/02/18 15:30:52 joko Exp $ +## $Id: rap.pl,v 1.3 2003/02/20 21:39:49 joko Exp $ ## ------------------------------------------------------------------------- ## $Log: rap.pl,v $ +## Revision 1.3 2003/02/20 21:39:49 joko +## - find_rules moved to Rap.pm +## +## Revision 1.2 2003/02/18 19:09:07 jonen +## + cwd for linux bootstrap +## ## Revision 1.1 2003/02/18 15:30:52 joko ## + initial commit ## @@ -13,9 +19,38 @@ use strict; use warnings; + +use File::Spec::Functions qw( splitpath splitdir catpath catdir ); + +sub popdir { + my $path = shift; + my $popcount = shift; + (my $volume, my $directory, my $file) = splitpath( $path ); + my @dir = splitdir($directory); + while ($popcount--) { + pop @dir; + } + #pop @dir; + + #my $base = catpath($volume, catdir(@dir)); + my $base = join('/', @dir); + $base = $volume . $base if $volume; + + return $base; +} + + + BEGIN { use FindBin qw($Bin); - use lib "$Bin/../../libs"; + #use lib "$Bin/../../libs"; + my $libpath = popdir($Bin, 2) . '/libs'; + #print "libpath: $libpath", "\n"; + #exit; + my $evs = "use lib '$libpath';"; + #print "evs: $evs", "\n"; + eval($evs); + die($@) if $@; } @@ -23,15 +58,12 @@ use Data::Dumper; use Data::Rap; -sub find_rules { - return '../etc/rap.xml'; -} sub main { my $argString = shift; - my $rulesfile = find_rules(); - my $rap = Data::Rap->new( filename => $rulesfile, target => $argString ); + my $rap = Data::Rap->new( target => $argString ); $rap->start(); + #$rap->stop(); } my @args = @ARGV;