http://qs321.pair.com?node_id=649907


in reply to Intermixed perl?

Turn the problem around. If you look at it as having Perl around command interpreter snippets, the problem becomes different:

#!/usr/bin/perl -w use strict; use vars qw($last_status); sub run_external { my $cmd = shift; print "Running [$cmd]"; $last_status = system($cmd); $last_sys_error = $?; return $last_status }; run_external(<<COMMAND); command1 param1=value1 param2=value2 COMMAND for my $machine (@machines) { run_external(<<COMMAND); command1 machine=$machine param1=value1 param2=value2 COMMAND if ($last_status) { run_external(<<COMMAND); debugging_command machine=$machine debug_param1=debug_va +lue1 COMMAND }; };

Of course, this requires you to start all your new/complex files with Perl and your simple files with the other interpreter/the shell. I would write a wrapper that checks (say) the file extension or whatnot to launch the correct interpreter for the program.

Replies are listed 'Best First'.
Re^2: Intermixed perl?
by sg (Pilgrim) on Nov 11, 2007 at 16:34 UTC