Problems with tabulations

L

Luca Francesca

Hello.
I've a program to extract some data from a file. ( http://pastebin.com/f3M6LuQw ).
The output of the program is not nice as i want (I used \t but isn't working well)

Any idea about a fix??

Thanks an good day all.

Luca
 
J

J. Gleixner

Hello.
I've a program to extract some data from a file. ( http://pastebin.com/f3M6LuQw ).
The output of the program is not nice as i want (I used \t but isn't working well)

Any idea about a fix??


Pretty poor code.. but to answer your question.. modify the outout
produced by 'print' as needed.. e.g. use printf instead of relying on
tab.

e.g. this line:

print "Service \t $service \n";

might produce nicer output as

printf "%-15s %s\n", 'Service', $service;

For other options and to explain what the '-' does, see:
perldoc -f sprintf
 
L

Luca Francesca

Il giorno martedì 6 novembre 2012 22:47:35 UTC+1, J. Gleixner ha scritto:
Pretty poor code.. but to answer your question.. modify the outout

produced by 'print' as needed.. e.g. use printf instead of relying on

tab.



e.g. this line:



print "Service \t $service \n";



might produce nicer output as



printf "%-15s %s\n", 'Service', $service;



For other options and to explain what the '-' does, see:

perldoc -f sprintf

Nice fix.
Thanks.
 
L

Luca Francesca

Il giorno mercoledì 7 novembre 2012 00:33:04 UTC+1, Ben Morrow ha scritto:
If you're producing formatted ASCII output, you might consider using

formats.



<duck>



(Or Perl6::Form, which is nicer and saner, and not really Perl-6-related

at all.)



Ben

I'll give it a shot ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,010
Latest member
MerrillEic

Latest Threads

Top