Awsome, regex worked! My head was stuck on chomp...Thanks Sheppy.

________________________________
From: Sheppy R <bobross...@gmail.com>
To: Bobby <cybercruis...@yahoo.com>
Cc: beginners@perl.org
Sent: Mon, November 8, 2010 2:32:13 PM
Subject: Re: Chomp help...

You could try doing this with a regex:

$html_content =~ s/\n//g;

This would look for any new-line ("\n") and replace it with nothing.  The g at 
the end tells it to do this globally, so all instances of \n would be removed.


On Mon, Nov 8, 2010 at 4:04 PM, Bobby <cybercruis...@yahoo.com> wrote:

Hi,
>
>I'm having issues with printing out the content of a Database's HTML text 
field;
>I wanted to chomp out the carriage returns of the $html_content(see below) so
>that I could print it out all in one line into a text file ($output). I've 
tried
>chomp() but it doesn't seems to work, does anyone have any suggestions on how I
>could accompolish this? Thanks.
>
>my %calls;
>while (my @row = $sth->fetchrow_array()) {
>  my ($base_no,$ad_zone,$url,$html_content) = @row;
>  open(OUT,">>$output") or die "Could not open $output: $!";
>     chomp;
>      print OUT "$ad_zone|$base_no|$url|$html_content\n";
>  close(OUT);
>}
>
>Desired Output for $output:
>ad_zone|base_no|url|html_content
>12|12000|http://www.yahoo.com|
>0 0 0; font-size:10px; color:#555;...</style>
>
>Content of $html_content:
><style>
>.homepageSeeDetails {
>       padding:0;
>       margin:-500 0 0 0;
>       font-size:10px;
>       color:#555;
>       display:block;
>       text-align:center;
>       width:700px;
>       text-decoration: none;
>       font-family: arial, helvetica, sans-serif;
>}
></style>
><script type="text/javascript">
>       function TB_popup(theURL) {
>         if (theURL != "")
>          {
>              var win =  window.open(theURL,
>"TBPopup","scrollbars=yes,width=550,height=600,top=0,left=235,resizable=yes");
>             win.focus();
>         }
>       }
></script>
>
>
>
>     



      

Reply via email to