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.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.

  • Comment on Re: Re: Re: Re: Re: Re: Re: Portability question: Is there something like '#ifdef' in Perl?
  • Select or Download Code

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
    That works and helps, thanks!
    -sureshr