in reply to Best way to change directories for a script?
As long as you are not using threads, I see nothing non-optimal in your solution.
My sleepy mind just inverted the solution; use a wrapper that just does chdir and exec the command.
Untested code:
Kludgey. I like your current method better.my $new_dir = "/usr/bin"; my $wrapper = 'perl -we chdir(shift)and(exec@ARGV)'; my($wtr, $rdr, $err); my $pid = open3( $wtr, $rdr, $err, "$wrapper $new_dir some cmd and args", );
|
|---|