Try this:

my $output=qq{sudo /usr/bin/python /home/processLog.py \Q$name\E \Q$ag +e\E \Q$text\E \Q$id\E}; return `$output`;
It works using interpolating quote-like operator qq{} and escaping operators \Q...\E, both described in Quote and Quote like Operators.

Another approach might be using open or modules like IPC::Run or IPC::Cmd to run a command with a list (not a string) of arguments:

open my $fh, "-|", qw{sudo /usr/bin/python /home/processLog.py}, $name +, $age, $text, $id or die $!; return do {local $/; <$fh>};
use IPC::Run; run [qw{sudo /usr/bin/python /home/processLog.py}, $name, $age, $text, + $id], ">", \(my $return) or die "run: $?"; return $return;

Warning: all code in this message is untested.

Update: using quotemeta for quoting shell commands is a hack, you should run a list of arguments instead, or use at least some shell-related module like String::ShellQuote.

Update 2: the code I suggested will discard any newlines in the interpolated variables instead of escaping them properly, so I stroke it out. Thanks ambrus for correcting me.

Edit: removed quotes from \Q...\E approach as they are entirely unnecessary in this case.

In reply to Re: Call Python script and pass arguments from Perl script by aitap
in thread Call Python script and pass arguments from Perl script by Ombongi.Moraa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.