in reply to Re: Re: Portability question: Is there something like '#ifdef' in Perl?
in thread Portability question: Is there something like '#ifdef' in Perl?
If you use the scalar args form of system
... system( "command \\path\\with spaces\\file" ); ...
you'll may have problems with the spaces.
If you use the list form of the system function.
... system( '\path\to\command.exe', '\path\with spaces\file' ); ...
Note the use of 's rather than "s, to avoid the need to escape the backslashes.
cmd.exe will be bypassed and the spaces in the filename won't cause a problem. However, you will need to specify the full path of the command as well.
You can also avoid the need for using short filenames by quoting the filepath.
... system( q[command "\path\with spaces\file" ] ); ...
Which allows the shell to resolve the location of the command for you and forces it to see the quoted path as a single argument.
Note though, if your in an open environment, the risk entailed in allowing your shell to do this for you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Portability question: Is there something like '#ifdef' in Perl?
by sureshr (Beadle) on Sep 29, 2003 at 19:32 UTC | |
by BrowserUk (Patriarch) on Sep 29, 2003 at 20:05 UTC | |
by sureshr (Beadle) on Sep 30, 2003 at 21:05 UTC | |
by BrowserUk (Patriarch) on Sep 30, 2003 at 21:26 UTC | |
by sureshr (Beadle) on Oct 01, 2003 at 20:40 UTC | |
by PodMaster (Abbot) on Oct 01, 2003 at 21:02 UTC |