in reply to Running Entire Bash Script Inside Perl
As for what you've posted, if you put the content of your __DATA__ block into an disk file, e.g. call it "foo.sh", then do system( "foo.sh" ) or maybe system( "/bin/sh", "foo.sh" ) then the subshell run by the system call would read the shell script from that file, and run it.
If the idea is to use perl to change some string in the shell script and then run it, then the trick I used in shloop might help you: open up a pipeline file handle that runs a shell, and then print shell commands to it:
open( SH, "|-", "/bin/sh" ) or die "can't launch a shell: $!\n"; my $param = "whatever"; print SH "echo hello\n"; print SH "echo $param\n"; print SH "echo hi\n"; close SH;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Running Entire Bash Script Inside Perl
by ikegami (Patriarch) on Jun 19, 2009 at 23:33 UTC | |
by graff (Chancellor) on Jun 19, 2009 at 23:48 UTC |