Inserting new line to a string

Discussion in 'Perl Misc' started by Deepan Perl XML Parser, Mar 24, 2008.

  1. Hi all,
    I am having a string like below:



    <responseStatus>HTTP/1.1 200 OK</responseStatus>

    <cookies></cookies>

    <headers>

    <header name="Accept-Ranges">bytes</header>

    <header name="Content-Encoding">gzip</header>

    <header name="Content-Length">5375</header>

    <header name="Content-Type">text/html</header>

    <header name="Date">Wed, 19 Mar 2008 10:00:30 GMT</header>

    <header name="ETag">&quot;1667999478&quot;</header>

    <header name="Last-Modified">Wed, 19 Mar 2008 10:00:01 GMT</header>

    <header name="Server">Cricbuzz- Blazing Fast</header>

    <header name="Vary">Accept-Encoding</header>

    </headers>

    <content>

    <contentLength>17958</contentLength>

    <compression>70.069</compression>

    <encodingScheme>gzip</encodingScheme>

    <text><![CDATA[

    <html>..<head>...</body>..<!-- The template body ends -->..</html>.

    ]]></text>

    <mimeType>text/html</mimeType>

    </content>



    ------------------------------------------------

    I want to insert new line at the end of every end tag[ex:- </
    responseStatus>].

    Thanks,
    Deepan
    Deepan Perl XML Parser, Mar 24, 2008
    #1
    1. Advertising

  2. Deepan Perl XML Parser wrote:
    > I am having a string like below:


    <html markup snipped>

    > I want to insert new line at the end of every end tag[ex:- </
    > responseStatus>].


    Even if I can't see the point, it's easily done using the s/// operator.

    perldoc perlop (about the s/// operator)
    perldoc perlrequick (about regular expressions)
    perldoc perlretut ("- )
    perldoc perlre ("- )

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Mar 24, 2008
    #2
    1. Advertising

  3. Deepan Perl XML Parser

    Ben Bullock Guest

    On Mar 24, 5:58 pm, Deepan Perl XML Parser <>
    wrote:
    > I am having a string like below:


    > I want to insert new line at the end of every end tag[ex:- </
    > responseStatus>].


    $mystring =~ s/<\//<\/\n/g;
    Ben Bullock, Mar 25, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugo
    Replies:
    10
    Views:
    1,288
    Matt Humphrey
    Oct 18, 2004
  2. kaushikshome
    Replies:
    4
    Views:
    744
    kaushikshome
    Sep 10, 2006
  3. scad
    Replies:
    23
    Views:
    1,129
    Alf P. Steinbach
    May 17, 2009
  4. ton
    Replies:
    3
    Views:
    1,491
  5. Marek Stepanek
    Replies:
    12
    Views:
    395
    Peter J. Holzer
    Sep 2, 2006
Loading...

Share This Page