2 |
## $Id$ |
## $Id$ |
3 |
## ---------------------------------------------------------------------- |
## ---------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.6 2003/03/27 15:31:05 joko |
6 |
|
## fixes to modules regarding new namespace(s) below Data::Mungle::* |
7 |
|
## |
8 |
|
## Revision 1.5 2003/03/27 15:03:03 joko |
9 |
|
## enhanced 'sub run_executable' |
10 |
|
## |
11 |
## Revision 1.4 2003/02/22 16:51:21 joko |
## Revision 1.4 2003/02/22 16:51:21 joko |
12 |
## + enhanced run_executable |
## + enhanced run_executable |
13 |
## modified logging output |
## modified logging output |
37 |
use Iterate; |
use Iterate; |
38 |
|
|
39 |
use shortcuts qw( run_cmd ); |
use shortcuts qw( run_cmd ); |
40 |
use Data::Code::Ref qw( ref_slot ); |
use Data::Mungle::Code::Ref qw( ref_slot ); |
41 |
use Data::Transform::Deep qw( expand ); |
use Data::Mungle::Transform::Deep qw( expand ); |
42 |
|
|
43 |
|
|
44 |
sub performTarget { |
sub performTarget { |
302 |
my $program = $opts->{executable}; |
my $program = $opts->{executable}; |
303 |
delete $opts->{executable}; |
delete $opts->{executable}; |
304 |
|
|
305 |
|
# determine execution method |
306 |
|
my $method = 'run_cmd'; |
307 |
|
my $wrapper_program = ''; |
308 |
|
|
309 |
|
# check if program is a namespace-string (contains '::') - use 'do' in this case! |
310 |
|
if ($program =~ /::/) { |
311 |
|
#if ($program =~ s/::/\\/g) { |
312 |
|
#$program = '.\\' . $program; |
313 |
|
#$method = 'require'; |
314 |
|
#do "$program"; |
315 |
|
#return; |
316 |
|
#$method = 'rap.'; |
317 |
|
|
318 |
|
$wrapper_program = 'rap.pl'; |
319 |
|
|
320 |
|
} |
321 |
|
|
322 |
|
# prepare arguments |
323 |
my @buf; |
my @buf; |
324 |
foreach (keys %$opts) { |
foreach (keys %$opts) { |
325 |
my $value = $opts->{$_}; |
my $value = $opts->{$_}; |
338 |
} |
} |
339 |
push @buf, "--$_=$value"; |
push @buf, "--$_=$value"; |
340 |
} |
} |
341 |
|
|
342 |
my $cmd = $program . ' ' . join(' ', @buf); |
# build {program} & {arguments} |
343 |
|
my $cmd = join(' ', $wrapper_program, $program) . ' ' . join(' ', @buf); |
344 |
|
|
345 |
# trace |
# trace |
346 |
#print "command: $cmd", "\n"; |
#print "command: $cmd", "\n"; |
353 |
$ENV{PERL5LIB} = $INC[0]; |
$ENV{PERL5LIB} = $INC[0]; |
354 |
|
|
355 |
#print Dumper(%ENV); |
#print Dumper(%ENV); |
356 |
run_cmd($cmd); |
|
357 |
|
print "command: '$cmd'", "\n"; |
358 |
|
|
359 |
|
# V1 - basic |
360 |
|
#run_cmd($cmd); |
361 |
|
|
362 |
|
# V1.b - enhanced: variable local method |
363 |
|
my $evalstr = "$method('$cmd');"; |
364 |
|
eval($evalstr); |
365 |
|
#my $res = do "$cmd"; |
366 |
|
#print $res, "\n" if $res; |
367 |
|
|
368 |
|
#$self->log("run_executable: $evalstr", 'info'); |
369 |
|
$self->raiseException("run_executable: $evalstr\n$@") if $@; |
370 |
|
|
371 |
# V2: via IPC::Run |
# V2: via IPC::Run |
372 |
# .... (TODO) |
# .... (TODO) |
373 |
|
|