laziness, impatience, and hubris | |
PerlMonks |
Re: running programs from PERLby jakobi (Pilgrim) |
on Oct 25, 2009 at 10:10 UTC ( [id://803133]=note: print w/replies, xml ) | Need Help?? |
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"?
cu & HTH, Peter -- hints may be untested unless stated otherwise; use with caution & understanding.
In Section
Seekers of Perl Wisdom
|
|