in reply to Re: Re: Re: Re: Re: Re: Portability question: Is there something like '#ifdef' in Perl?
in thread Portability question: Is there something like '#ifdef' in Perl?
You need to quote the command as well if it contains spaces. ie. This will work as. The inner, backslash-escaped quotes will be passed to the shell.
my $ret = system( "\"D:\\Program Files\\bin\\t.pl\"" );
However, rather than having to escape the inner quotes and double the backslashes, it's easier to make use of perls profusion of quoting operators.
my $ret = system( q[ "D:\Program Files\bin\t.pl" ]);
or
my $ret = system( '"D:\Program Files\bin\t.pl"' );
As an example
P:\test>copy con "d:\program files\test.pl8" print "Hi there! from $0"; ^Z 1 file(s) copied. P:\test>perl system( '"d:\program files\test.pl8"' ) and warn 'Failed with: ', $?; ^Z Hi there! from D:\program files\test.pl8 P:\test>
Hope that clarifies things a bit.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Re: Re: Re: Portability question: Is there something like '#ifdef' in Perl?
by sureshr (Beadle) on Oct 01, 2003 at 20:40 UTC |