Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Continuation and Concatination

Status
Not open for further replies.

rhnewfie

Programmer
Jun 14, 2001
267
CA
Is there a way to concatenate output to a file and use continuation characters to make my vode mre readable?? Right now I have this:

print "Content-type: text/plain\n\n ";
print OUTPUT "$contents{'firstname'}\n";
print OUTPUT "$contents{'lastname'}\n";

which puts everything on a separate line but I want everything on one line (there's a lot more field values to output). I was wondering if there is anything like:

print "Content-type: text/plain\n\n ";
print OUTPUT "$contents{'firstname'} & _
print OUTPUT "$contents{'lastname'}\n";

or something similar

thanks
RHNewfie There are 3 Types of People in the World
Those Born to Think Logically
Those that can Learn to Think Logically
Those that Shouldn't Try
 
The only thing that's making each item print on a separate line is that you're using text/plain, and each line ends with a linefeed (\n). If you don't want them printed that way, just remove the \n from all but the last item, and put spaces or some other character in their place. Example:
Code:
print "Content-type: text/plain\n\n ";
print OUTPUT "$contents{'firstname'}  ;
print OUTPUT "$contents{'lastname'}  ";
print OUTPUT "$contents{'city'}  ";
print OUTPUT "$contents{'lastname'}\n";
Note: DO NOT change the content type line! Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Alternatively you can also write your code as:

print "Content-type: text/plain\n\n ";
print OUTPUT "$contents{'firstname'}".
"$contents{'lastname'} ".
"$contents{'city'} ".
"$contents{'lastname'}\n";

as the "." character is the concatenation character, that I think you were after. Note that you don't need to add the "print OUTPUT" to the beginning of subsequent lines.

HTH,
Barbie.
Leader of Birmingham Perl Mongers
 
Or, you can do it with just two print statements, like this:
Code:
print "Content-type: text/plain\n\n ";
print OUTPUT "$contents{'firstname'}  $contents{'lastname'}  $contents{'city'}  $contents{'lastname'}\n";
That last line is all on one line, no matter how TT shows it. Lines of code in perl can be quite long if you need them to be. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top