having another problem with perl and regex, sorry for being a badass perl noobie 😉
I get the whole programm output via backticks in the variable $output.
My regex matches always just for the first appearing in the output but not for every appearance..
/g didn’t work either..
$output = `$calling 2>>bla.txt`;
if ($output =~ m/SegmentMean .+ Likelihood: ([-+]?\d+\.?\d+)/g) {
print "$1\n";
}
Outputs from the Java Output is:
SegmentMean 0 Likelihood: -7.138117738068088
SegmentMean 1 Likelihood: -11.508156736772925
SegmentMean 2 Likelihood: -10.424706822552386
SegmentMean 3 Likelihood: -9.560308776447586
SegmentMean 4 Likelihood: -9.26826400149502
SegmentMean 5 Likelihood: -9.524685714290996
SegmentMean 6 Likelihood: -8.360030637461975
SegmentMean 7 Likelihood: -8.163275211919945
SegmentMean 8 Likelihood: -7.917569593466525
SegmentMean 9 Likelihood: -9.043243571260344
Up to SegmentMean 20 ..
Try going through the matches like an array (and use a better regex):
That should work.
You can even turn it into a single line: