REGEX in QString isnt passed correct to QProcess
-
Hi,
with the code below i load a file named fileName into a perlscript.
With the regex (!/^$/) i get rid of all lines that starts with a $ .
the rest is put into a variable alllines.
after that the program is passed into a QProcess and all the output directed to QListView.I get the following error
Fehler:unknown escape sequence '$'
my idea is that the regex !/^$/ is the problem.
@
oid EngMountStiff::on_commandLinkButton_clicked()
{QString aScript = "$file = \""+fileName+"\";" "print $file;" " open(PCH, $file); # Open the file " " while (<PCH>) { " " if (!/^\$/) " " { " " push(@alllines,$_); " " } " "} " "close(PCH); # Close the file " "print @alllines;"; //start perlscript QProcess perl; QString perlscript = "/usr/bin/perl"; perl.start(perlscript); perl.write(aScript.toUtf8()); perl.closeWriteChannel(); perl.waitForFinished(-1); perl.setProcessChannelMode(QProcess::MergedChannels); QString p_stdout = perl.readAllStandardOutput(); QString p_stderr = perl.readAllStandardError(); //stream in processwindow ui->output->setText(p_stderr); ui->output->setText(p_stdout);
@
-
Escape it properly, then:
@
" if (!/^\$/)"
@ -
I am sorry but than the regex isnt working correct.
But u are rigth the programm is running. -
Try with simpler scripts (a hello world or something) to see if Perl is really working well from within QProcess.
-
Allready done. Simple hello world is working and only printing the file fileName is also ok.
Do you have an idea how to ouput the resulting qstring (aScript), after it is processed, so i can see how the \$ is translated?