-----Original Message-----
From: Chris Share [mailto:[EMAIL PROTECTED]
Sent: Friday, October 20, 2006 3:24 PM
To: beginners@perl.org
Subject: Where are These Carriage Returns Coming From?
Hi,
In the output of the following code there's a carriage return between
the $name variable and the "!". Where is this coming from? Doesn't the
chomp get rid of this?
#!/usr/local/bin/perl
$| = 1;
use strict;
use warnings;
use CGI qw(:standard);
print "What is your name? ";
my $name = <STDIN>;
chomp $name;
print header;
print start_html(-title=>"Hello $name!\n", -bgcolor=>"#cccccc",
-text=>"#999999");
print "<h2>Hello, $name!</h2>\n";
print end_html;
Here's the output:
What is your name? Chris
Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Hello Chris
!
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body bgcolor="#cccccc" text="#999999">
<h2>Hello, Chris
!</h2>
</body>
</html>
Remove the "\n" that you are printing after $name in both the lines.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
"Legal Disclaimer: This electronic message and all contents contain information
from Cybage Software Private Limited which may be privileged, confidential, or
otherwise protected from disclosure. The information is intended to be for the
addressee(s) only. If you are not an addressee, any disclosure, copy,
distribution, or use of the contents of this message is strictly prohibited. If
you have received this electronic message in error please notify the sender by
reply e-mail to and destroy the original message and all copies. Cybage has
taken every reasonable precaution to minimize the risk of malicious content in
the mail, but is not liable for any damage you may sustain as a result of any
malicious content in this e-mail. You should carry out your own malicious
content checks before opening the e-mail or attachment."
www.cybage.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>