EchoAngel has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I have problems with sending values. IE.
my $returnvalue = "$pin=" . &TransformBooleanEquation($functi +on) if (length($function) > 0); print "[RETURN] $returnvalue\n";
what i see at the output is : RETURN S=(((\!CS)&(A^B^\!CI0N))|(CS&(A^B^\!CI1N))).
my $outputValueFromFindArcsScript = system("/proj/dance.pl '$ +returnvalue'") if (length($function) > 0);
now when i do this, it fails. If i wanted to do this manually in the terminal window, I execute the code below and it works.
/proj/dance.pl 'S=(((\!CS)&(A^B^\!CI0N))|(CS&(A^B^\!CI1N)))'
why won't my perl code execute this?

Replies are listed 'Best First'.
Re: Problems with sending value to system command
by Errto (Vicar) on Dec 04, 2004 at 01:42 UTC
    The builtin system does not return the text that the called program writes to standard output. For that you should use the backtick operator (``). But I have a question for you. Why call one Perl program from another as a separate process? Why not just modify the called program to have a subroutine return a value instead of printing it out and then make it a module?
      i tried using the backtick operator. the problem is that when the system command is called, the script doesn't operator and dies
        You can't combine system() and the backtick operator. Try
        my $outputValueFromFindArcsScript = `/proj/dance.pl '$returnvalue'` if + (length($function) > 0);
Re: Problems with sending value to system command
by dave_the_m (Monsignor) on Dec 04, 2004 at 12:52 UTC
    Never have an if statement modifier on the end of a statement containg a my declaration. It will do Strange Things related to old values hanging aroung from previous calls to the enclosing block. ie replace
    my $x = .... if $y;
    with
    my $x; $x = .... if $y;

    Dave.

      I found out that the reason it doesn't work is that I must not include the \! within the value when sending through Perl. However, on the command line, the \! must be included.