LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 09-07-2004, 01:29 PM   #1
knnirmal
LQ Newbie
 
Registered: Sep 2004
Posts: 2

Rep: Reputation: 0
Unhappy 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.
 
Old 09-07-2004, 01:41 PM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
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

Last edited by Cedrik; 09-07-2004 at 01:43 PM.
 
Old 09-07-2004, 03:27 PM   #3
knnirmal
LQ Newbie
 
Registered: Sep 2004
Posts: 2

Original Poster
Rep: Reputation: 0
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>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python: find defined text string in a file, and replace the whole line Dark Carnival Programming 6 05-22-2007 07:02 AM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 02:04 AM
PERL:: trying to remove last line of file ocularbob Programming 16 09-01-2003 02:07 PM
trying to search and replace text file for single & multiple line breaks separately brokenfeet Programming 7 08-29-2003 02:56 PM
perl: replacing a special line in a file markus1982 Programming 1 09-26-2002 03:05 PM


All times are GMT -5. The time now is 08:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration