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

Printing data out in columns?

Status
Not open for further replies.

StormMedic85

Programmer
Sep 7, 2007
20
US
Anyone have any suggestions of how to print numerical data out to a file in neatly organized columns? I've seen it done with a for loop, but I'm thinking formatted print. Any ideas?

Thanks!
 
Hello Storm,

Do you mean like this for example?...

Code:
1   11    444
2   111   555
3   12    444
4   122   555
5   13    444
6   133   555
7   14    444
8   144   555
9   15    444
10  155   555

Chris
 
you can always tab seperate them
print "$data\t$data1\t$data2";

if you search I believe you will find that you can use sprintf or printf to format it for you also

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Thanks for all the suggestions! A current method I tried that seems to work is something along the lines of doing it within a for loop...

for ($i=0; $i<$size; $i++) {
print "$pressure[$i]\t$temperature[$i]\t$rh[$i]\t$uwind[$i]\t$vwind\n";
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top