perlwww-mechanizewww-mechanize-firefoxmozrepl

How to enter text into textbox using MozRepl if the text has backslashes in it as part of the text?


my @para_text = (
"The build of $build CUT$cut was started as requested and 
its progress can be monitored in Anthill here", 
"",
"http://anthill:8080/tasks/project/BuildLifeTasks/viewBuildLife?
buildLifeId=$lifeid", 
"", 
'If it completes successfully (Overall Anthill status will show as green 
Complete and all sub steps as green Success) the built output will be 
available for deployment and testing by first copying the zip file from here 
\\\mizar\release\AnthillRelease\$build', 
"", "If the output exists but the anthill build was not completely 
successful DO NOT attempt to copy and deploy the output. \n", 
"We will send the usual email detailing content etc. when the build 
finishes. \n");

$para_text[0] =~ s/[\r\n]//gm;    # convert multiline to single line

@para_text = join "\n", @para_text;

s/([\\"])/\\$1/g, s/\n/\\n/g for @para_text;

$mech->eval_in_page( qq/document.getElementsByName("txtbdy")[0].value = "@para_text", "test"/ );

I have the above code.

The array holds a email template and the script is made around the Outlook webapp using WWW::Mechanize::Firefox.

The email template has a directory in it which has backslashes.

MozRepl does not allow backslashes or any special characters when putting the text into the text box at the $mech->eval_in_page line.

How can I put backslashes in the text if it's not allowed by the module?


Solution

  • I removed the backslashes from my code and used this line to substitute them in

    $para_text[4] =~ s{!}{\\}g;
    

    Problem Solved. Substituting a character for the backslashes later on works.