I want to execute python script from perl code. I want to save python output to array and get some data from it. Python script will do some search in disk and locate files which I need. I will use that output and play with it in my next script.
I wrote some code
use strict;
use warnings;
use Getopt::Long;
my $opt_section;
my $opt_content;
my $opt_ver;
my $opt_help = 0;
&GetOptions (
"help" => \$opt_help,
"section:s" => \$opt_section,
"content:s" => \$opt_content,
"ver:s" => \$opt_ver,
);
if ($opt_help) {
print "USAGE: file.pl -section <section> -content <content> -ver <ver> \n ";
exit;}
###################python script stats here ################
my $py = `/home/priya/library/bin/find.py -filter test~${opt_section}_priya_${opt_ver}` ;
print "output is $py \n";
code is executing python script and displaying output on the terminal screen. But it is not storing output to $py. Can you please hep me to direct all output to an array or scalar? later I want to use every line of python output.
my @output = qx(... 2>&1)(qx() is same as backticks)