Problems with tabulations

Discussion in 'Perl Misc' started by Luca Francesca, Nov 6, 2012.

  1. 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
     
    Luca Francesca, Nov 6, 2012
    #1
    1. Advertising

  2. Luca Francesca

    J. Gleixner Guest

    On 11/06/12 15:30, Luca Francesca wrote:
    > 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
     
    J. Gleixner, Nov 6, 2012
    #2
    1. Advertising

  3. Il giorno martedì 6 novembre 2012 22:47:35 UTC+1, J. Gleixner ha scritto:
    > On 11/06/12 15:30, Luca Francesca wrote:
    >
    > > 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


    Nice fix.
    Thanks.
     
    Luca Francesca, Nov 7, 2012
    #3
  4. Il giorno mercoledì 7 novembre 2012 00:33:04 UTC+1, Ben Morrow ha scritto:
    > Quoth "J. Gleixner" <>:
    >
    > > On 11/06/12 15:30, Luca Francesca wrote:

    >
    > > > 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;

    >
    >
    >
    > 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 ;)
     
    Luca Francesca, Nov 7, 2012
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Srinivas Kanakapally [MSFT]

    RE: Vs.net Server Explorer Diagram Problems

    Srinivas Kanakapally [MSFT], Jul 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,042
    Srinivas Kanakapally [MSFT]
    Jul 8, 2003
  2. BestNews
    Replies:
    0
    Views:
    3,203
    BestNews
    Aug 20, 2003
  3. Susan Baker
    Replies:
    2
    Views:
    865
    kelvSYC
    Jun 26, 2005
  4. Shelly

    Problems, problems for newbie

    Shelly, Sep 2, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    2,245
    Shelly
    Sep 3, 2007
  5. Sak Na rede
    Replies:
    0
    Views:
    445
    Sak Na rede
    Jan 30, 2009
Loading...

Share This Page