in reply to Re: How to print bunch of data in a file without breaking in to new line
in thread How to print bunch of data in a file without breaking in to new line

Hi,

Thanks, for your quick response.

I have stored all the contents of a HTML file in a variable. While i'm printing the data in a file, the content breaks in to new line exactly where the closing tag </p> or </span> or </div> appears, but it should not.

  • Comment on Re^2: How to print bunch of data in a file without breaking in to new line
  • Download Code

Replies are listed 'Best First'.
Re^3: How to print bunch of data in a file without breaking in to new line
by zentara (Cardinal) on Jul 31, 2012 at 16:45 UTC
    It can get confusing with html documents, because the html bracket return acts as a newline. Here is a simple way to clean your html.
    #!/usr/bin/perl use warnings; use strict; open (FH,"< zz.html") or die "$!\n"; read( FH, $buf, -s FH ); close FH; #print "$buf\n"; $buf =~ s/\n//g; # strips out all newlines open (OH,"> zz_out.html") or die "$!\n"; print OH $buf; close OH; # zz_out.html will not have any newlines when viewed with a text edito +r, but will still be viewable in a web browser

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh