in reply to running programs from PERL
Beyond Alexander's tips, there's one more thing that bugs me:
You chdir to $current_dir, then prepend $current_dir/ to your command. Works nicely on Unix for $current_dir being absolute or . or ./. . But for "" or a non-trivial relative path, you're in for a surprise... .
One way to cope is prepending $ENV{PWD}/ to a relative path. Note that $ENV{PWD} isn't updated by chdir(), being set by the shell. Note 2: Better yet, check Anonymous' File::chdir pointer below and prepend $CWD instead (thx, this elimininates most of the chdir pains! Note2Self: my($CWD) stops the chdir side effect of assigning. Good.).
Ad afoken's warning on using the shell:
If you restrict yourself to Unix (and CYGWIN), you normally can assume at least a Bourne-style or POSIX shell, which allows a nice idiom using %ENV to avoid severe secure quoting headaches: $ENV{f}="...";system qq{ls -l -- "\$f"};.
Open Question: Windows processes should support %ENV as part of their POSIX support. What is be the corresponding secure Windows-NON-CYGWIN-idiom for the Unix shell's variable interpolation w/o word splitting, i.e. "$f"?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: running programs from PERL
by cdarke (Prior) on Oct 25, 2009 at 13:01 UTC | |
by jakobi (Pilgrim) on Oct 25, 2009 at 14:43 UTC | |
|
Re^2: running programs from PERL
by Anonymous Monk on Oct 25, 2009 at 10:34 UTC |