CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: General Discussions: General Questions:
Line Breaks/Returns

 



ssmythe
New User

Oct 31, 2011, 9:40 AM

Post #1 of 2 (6028 views)
Line Breaks/Returns Can't Post

I'm have a problem with preserving line breaks. When the user fills in their company description on the form line breaks appear but when the data comes from the database the line breaks disappear! Can anyone help?

print $thebest->{cgi}->header;
my @company;
my $ctitle = "Company Description";
my $keywords = "Company Keywords";
my $cdescription = "Company Description";
my $companies = $thebest->database("getCompany", { "company_id" => $cid, geolocation => $geolocation });
use Data::Dumper;
foreach (@$companies) {
my $item = $_;
if($item) {
$item->{hash} = $thebest->auth("md5string", { "string" => "$item->{id}" });
if($item->{reviews_total} == 0) {
$item->{stars} = 0;
} else {
$item->{stars} = int($item->{reviews_total} / ($item->{reviews} - 1));
}
$ctitle = $item->{name}.": ".$item->{keywords};
$keywords = $item->{keywords};
my (@desc) = split(//, $item->{description});
my $adesc;
my $rowc = 0;
my $count = 0;
my $total = @desc;
while($count < $total) {
if($rowc == 60) {
$adesc .= @desc[$count];
$rowc = 0;
} else {
$adesc .= @desc[$count];
}
$rowc++;
$count++;
}
$item->{description} = $adesc;
$cdescription = $item->{sdescription} ;
push(@company, $item);

}


BillKSmith
Veteran

Nov 2, 2011, 7:05 AM

Post #2 of 2 (5771 views)
Re: [ssmythe] Line Breaks/Returns [In reply to] Can't Post

The safest "solution" is to chomp newlines from all inputs.
Add them to print statements when needed.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives