Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > carriage returns in HERE statements

Reply
Thread Tools

carriage returns in HERE statements

 
 
bdz
Guest
Posts: n/a
 
      02-26-2007
I am running Ubuntu GNU/Linux Edgie.

I have a program that is using a here statement to print a message in
a terminal window.

sub info {
print << "HERE"
\~\~\~\~\~\~\~\~\~\~\~\~\n
Line 1 \n
Line 2 \n
Line 3\n Line 4\nLine 5 \n

\~\~\~\~\~\~\~\~\~\~\~\~\n
HERE
}

The message is printed out in this fashion

~~~~~~~~~~~~

Line 1

Line 2

Line 3
Line 4
Line5

~~~~~~~~~~~~

That is the carriage returns not marked by \n in the script are
printing to the
terminal as carriage returns giving me double spaced lines unless I
group all the lines on one line (as in 3,4,and 5.

I did not have this problem when I was using HERE statements under my
previous (obscure non-windows) operating system. Can anyone illuminate
this matter?

 
Reply With Quote
 
 
 
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      02-26-2007
On Feb 26, 10:28 am, "bdz" <(E-Mail Removed)> wrote:

> That is the carriage returns not marked by \n in the script are
> printing to the terminal as carriage returns


You typed the program output (and made three typoos in the process) -
please don't do that. cut-and-paste instead.

Your program is apparently producing the correct output (we don't know
for sure, since you typed the output instead of cut-and-paste). When
you use a heredoc, every single character is included (including any
newlines that you put in the text by way of hitting your ENTER key).
If you terminate a line with a \n you get two newlines - one that you
included by hitting ENTER and one that you included by typing \n.

If you saw different behavior from another program it's probably
because $\ had been redefined.

--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)

 
Reply With Quote
 
 
 
 
bdz
Guest
Posts: n/a
 
      02-27-2007
Thanks for the explanation. I am sorry I typed it, i was trying to
simplify. However knowing that the newlines that are in the text will
print to the terminal without having to put in a \n solves my problem.
Amigas do not respond that way when here documents are used in a
terminal but I am aiming for cross OS capability.

Thanks for your useful comments on my typing. I see the three
"typoos", forgetting the ; after "HERE" and Line5 instead of Line 5
in the output and the code should have produced two blanks before the
final set of tildes.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Xyplex double carriage returns when using tftp Chris_D Cisco 1 02-19-2006 10:16 PM
How to match carriage returns and line feeds Schroeder Perl 1 01-26-2005 06:53 PM
Help: Delete a single carriage return in a file, but not a double carriage return? Steve Anderson Perl Misc 3 06-21-2004 12:48 AM
Replacing Carriage Returns in VB.NET Mario Vargas ASP .Net 3 11-10-2003 04:47 PM
Carriage Returns and sockets Iceberg Perl 1 09-06-2003 04:49 PM



Advertisments