Perl - Tpl file - Need to replace new line character.
Hi, m brand new to Perl programming..
We have one .tpl file, which has code to read data from xml file and generate html using this data. xml data has new line characters. We want to remove this new line character before generating html file. Following is javascript code which is creating prob: newdocument.write('<iw_value name='dcr.Important Information' />'); Here '<iw_value name='dcr.Important Information' />' returns string having new line character. |
You can also use tr to delete one char :
cat xml_file.xml | tr -d '\n' > xml_file.xml.new or if the file is read line by line inside Perl script, just : chop $line; will do |
Have found solution:
Following code works fine. Thanks to all of u.. <iw_perl><![CDATA[ my $str = iwpt_dcr_value( 'dcr.Important Information' ); $str =~ s/\n/<br \/>/g; $str =~ s/\'/\\'/g; iwpt_output("newdocument.write('$str');"); ]]> </iw_perl> |
All times are GMT -5. The time now is 04:40 PM. |