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 (!/^\$/)"
@ -
Try with simpler scripts (a hello world or something) to see if Perl is really working well from within QProcess.