formatting output to align properly

Posted on 2011-04-22
Last Modified: 2012-05-11
I have to print something like this

Name   ID     Details
-----      ------    ---------
ambuli  25        StreetName,
some    30        someStreet,
That is, the third column would have multiple lines, and I should arrange the column properly.  Thanks.
Question by:ambuli
    LVL 31

    Expert Comment

    If the above is the output what is the input?

    Author Comment

    Assuming that the names, and addresses, etc are available within a program in some data structures.  I am working on a slightly large program and it would be confusing to look at the whole code :-)
    LVL 31

    Accepted Solution

    Why don't you simply using C-style printf.  It works in Perl.

    Suppose you want to print a string in 10 character spaces the you print it as

    printf("%10s", $name);


    Author Comment

    oh, I did not know it.  Thanks.

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
    There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now