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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can you remove new lines when using <<SAVING; 1

Status
Not open for further replies.

millimeter

Programmer
Mar 30, 2002
12
US
When using the following routine I am getting a new line in the text file I am writing. Anyway to prevent this;

$somevalue= $in{"somevalue"};
chomp ($somevalue);
open(HEADINGFILE, ">filename.txt");
print HEADINGFILE <<SAVING;
$somevalue
SAVING
close(HEADINGFILE);
 
Why are you using the <<SAVING thing anyway when you're just printing one line? Why not just say
print HEADINGFILE $somevalue;

?
 
Thanks Krel... that was the solution.
The reason I used it is because when I first started learning I used it successfully for multi-line and never ran into any reasons to try anything else till now... still learning!

Thanks.[thumbsup2]
 
Here documents, as they are called within UNIX systems, were originally used to preserve the spacing and formatting of output. As such any newlines, tabs, etc are written to your file as they are written within the here document.

HTH,
Barbie. Leader of Birmingham Perl Mongers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top