in reply to Problem passing a string in system function

I see no obvious reason why it shouldn't work. You may try using the multiple arguments version of system, though. From perldoc -f system:

If there is only one scalar argument, the argument is checked for shell metacharacters, and if there are any, the entire argument is passed to the system's command shell for parsing

But while we're here I feel like repeating the (now) daily question: why don't you make mycode.pl into a real module?

Replies are listed 'Best First'.
Re^2: Problem passing a string in system function
by Anonymous Monk on May 19, 2006 at 14:22 UTC
    Ok, actually the system call is run under Acme::Spork.
    Could it be the cause?
    use Acme::Spork; my $req_id = spork( sub { system("perl mycode.pl -email \"$uemail\" +-type $sometype -unit $someunit"); } ) or die qq {Could not fork for spork: $!};
    I can't turn  mycode.pl into a real module. Coz in real situation it is a executable binary.

      I don't know anything abour Acme::Spork, so I can't guess if it's the problem or not. But if you remove it from the equation, and use the system call normally, do you have the same problem? If removing it corrects the problem, I would contact the author for assistance

      Ok, actually the system call is run under Acme::Spork. Could it be the cause?
      Easiest, securest way to find if Acme::Spork (never heard of it) is the cause: take it out of the equation and test it!

      Just write:
      #!/usr/bin/perl -w use strict; my $uemail = 'foo@bar.com'; system("perl mycode.pl -email \"$uemail\"") or die "Well, probably NOT + a spork problem";

      or better yet, comment the spork line of your code and do a simple system call as above. Either way will tell you if this module is or is not the cause of your problem.

      <UPDATE> My apologies to HuckinFappy. I ended up answering the same thing...</UPDATE>

      Just my two cents.