Formatting Perl Output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting Perl Output
# 1  
Old 07-07-2010
Bug Formatting Perl Output

Hi,

I am getting the output from a PERL program but the output is all on different lines.

My code is
Code:
printf hOUT "%s\t%s\t%s\t%s\t%s\t%s",$M1_CTR, $M2_CTR, $M3_CTR, $M4_CTR, $M5_CTR, $M6_CTR;

Example:

My report (which I send via email) should look like this

Area 1 Area 2 Area 3 Area 4 Area 5 Area 6
30 299 7 66 53 12


But instead Iam getting
Area 1 Area 2 Area 3 Area 4 Area 5 Area 6

30
299
7
66
53
12

How do I format the output so they all appear on one line?

Any suggestions to fix this?

Also, Iam new to perl and I need to complete this by Thursday(7/8)

Thanks
nurani
# 2  
Old 07-07-2010
Code:
chomp ($M1_CTR,$M2_CTR,$M3_CTR,$M4_CTR,$M5_CTR,$M6_CTR);
printf hOUT "%s\t%s\t%s\t%s\t%s\t%s",$M1_CTR, $M2_CTR, $M3_CTR, $M4_CTR, $M5_CTR, $M6_CTR;

# 3  
Old 07-07-2010
Bug It worked

Hi,

I implemented the chomp command and it worked. But as a follow up to that, If I want to space out the numbers nicely underneath the headings, what do I do for that.

Rightnow the numbers come like this

33 55 100 271 90 1

Basically, right align and left align of the numbers.

Note :- I did try chomp and chop earlier but I did it on each of the output
values (which did not make any difference) - Rather than doing it
on the list

Thanks
nurani
# 4  
Old 07-08-2010
Hi.

See post # 5 in https://www.unix.com/shell-programmin...t-problem.html for a link to an alignment tool (in perl) ... cheers, drl
# 5  
Old 07-08-2010
Bug Formatting

Hi,

I can't use align. I did try to use it and I got bunch of errors. Due to lack of time, I would like go with printf.

Is there a way I can pad spaces using printf command.

My existing printf command looks like this. Could you please edit this code so I can just use it as is.

Code:
printf hOUT "%s\t%s\t%s\t%s\t%s\t%s",$M1_CTR, $M2_CTR, $M3_CTR, $M4_CTR, $M5_CTR, $M6_CTR;

All I want is to pad spaces to each of the counters so they align with their column headings. Rightnow, they are not aligned.

I need this resolved (working) by today (Thursday)

Thanks
nurani
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formatting of output

Hi, I have some output in the format below: Col-A Col-B 8781 4319 8781 2332 8781 0269 5550 3282 5550 9465 5550 7607 7064 4456 . . I want to re-format the output so i will get something like this: 8781:4319,2332,0269 5550:3282,9465,7607 7064:4456 for... (6 Replies)
Discussion started by: james2009
6 Replies

2. Shell Programming and Scripting

Formatting the output

Hi, I have a file which contents entries in this form. Only in /data4/temp abc.000001 Only in /data4/temp abc.000003 Only in /data4/temp abc.000012 Only in /data4/temp abc.000120 Only in /data4/temp abc.000133 Only in /data4/temp abc.001444 i want to read line by line and format... (2 Replies)
Discussion started by: arijitsaha
2 Replies

3. Shell Programming and Scripting

Output Formatting

Hi Guys I need help removing some lines from output i am receiving from a shell script. Here is the output: http://i52.tinypic.com/10z0fut.png I am trying to remove the output that i have circled. . ${EDW}/extracts/bin/extracts_setup2.sh . ${EDW}/extracts/extracts.conf ... (7 Replies)
Discussion started by: mooey1232003
7 Replies

4. Shell Programming and Scripting

Formatting of output

Hi Experts, I have to create a report for certain audit and my output looks as follows I m trying to format my output to look like Any inputs would be highly appreciated Thanks Syed (5 Replies)
Discussion started by: maverick_here
5 Replies

5. Shell Programming and Scripting

perl ssh2 output formatting

Hi Experts, I am using following format for Perl SSH2 commands. #!/usr/bin/perl -w use Net::SSH::Perl; use POSIX; use Sys::Hostname; use Term::ANSIColor qw(:constants); use strict; #my $host="10.128.0.214"; my @nodeip = ("10.128.0.214","10.128.0.215") ; my %node =... (7 Replies)
Discussion started by: mtomar
7 Replies

6. Shell Programming and Scripting

more help with formatting ls output...

Ok, for a fun project, my goal is to replicate the style of "catalog" on an old apple ] *A 002 SOMEAPPLESOFTFILE B 004 SOMEFILE T 006 SOMETEXT I 002 SOMEINTEGERFILE The first character is either " " or "*" depending on if the file is locked or not. Next is the filetype, so in... (1 Reply)
Discussion started by: patrick99e99
1 Replies

7. Shell Programming and Scripting

formatting the output

Is it possible to convert the attached file to the format mentioned. Here for a particular job the table name and the corresponding instance name from one test run "X" is compared with the table name and the instance name from the second test run "Y" for output rows,affected rows,applied... (1 Reply)
Discussion started by: ragavhere
1 Replies

8. Shell Programming and Scripting

formatting output

Hi need some advice.. #grep -i hostname test.csv (gives the below output) HOSTNAME,name,host_test,,,,,,,, Now I need to format the above output as below. HOSTNAME: name=host_test Any easy way of doing this using awk or sed or printf? (4 Replies)
Discussion started by: balaji_prk
4 Replies

9. Shell Programming and Scripting

Formatting output

Hi, I am new to shell scripting, I ahve written a shell script which would extract me data, but my problem is I want to add a column name to my output. Using grep and sed I am getting my data from the input file. Sample data name : eric name : tom name : sean My output using grep and sed... (3 Replies)
Discussion started by: illur81
3 Replies

10. Shell Programming and Scripting

Formatting the output

Hi all, Have the following code(1) producing the results(2 & 3). Would like to know if there is a way to format the two reports created in a similar fashion. IE - The first is formatted nicely as a result of the echo "$xmpbdate $xavgs" >> $xmpbrpt However when I attempt to do the same on... (7 Replies)
Discussion started by: Cameron
7 Replies
Login or Register to Ask a Question