--- nfo/perl/libs/Data/Rap/Engine.pm 2003/02/22 16:51:21 1.4 +++ nfo/perl/libs/Data/Rap/Engine.pm 2003/03/27 15:03:03 1.5 @@ -1,7 +1,10 @@ ## ---------------------------------------------------------------------- -## $Id: Engine.pm,v 1.4 2003/02/22 16:51:21 joko Exp $ +## $Id: Engine.pm,v 1.5 2003/03/27 15:03:03 joko Exp $ ## ---------------------------------------------------------------------- ## $Log: Engine.pm,v $ +## Revision 1.5 2003/03/27 15:03:03 joko +## enhanced 'sub run_executable' +## ## Revision 1.4 2003/02/22 16:51:21 joko ## + enhanced run_executable ## modified logging output @@ -296,6 +299,24 @@ my $program = $opts->{executable}; delete $opts->{executable}; + # determine execution method + my $method = 'run_cmd'; + my $wrapper_program = ''; + + # check if program is a namespace-string (contains '::') - use 'do' in this case! + if ($program =~ /::/) { + #if ($program =~ s/::/\\/g) { + #$program = '.\\' . $program; + #$method = 'require'; + #do "$program"; + #return; + #$method = 'rap.'; + + $wrapper_program = 'rap.pl'; + + } + + # prepare arguments my @buf; foreach (keys %$opts) { my $value = $opts->{$_}; @@ -314,8 +335,9 @@ } push @buf, "--$_=$value"; } - - my $cmd = $program . ' ' . join(' ', @buf); + + # build {program} & {arguments} + my $cmd = join(' ', $wrapper_program, $program) . ' ' . join(' ', @buf); # trace #print "command: $cmd", "\n"; @@ -328,7 +350,21 @@ $ENV{PERL5LIB} = $INC[0]; #print Dumper(%ENV); - run_cmd($cmd); + + print "command: '$cmd'", "\n"; + + # V1 - basic + #run_cmd($cmd); + + # V1.b - enhanced: variable local method + my $evalstr = "$method('$cmd');"; + eval($evalstr); + #my $res = do "$cmd"; + #print $res, "\n" if $res; + + #$self->log("run_executable: $evalstr", 'info'); + $self->raiseException("run_executable: $evalstr\n$@") if $@; + # V2: via IPC::Run # .... (TODO)