NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

This node was taken out by the NodeReaper on Oct 07, 2011 at 18:55 UTC

Replies are listed 'Best First'.
Re: print format
by BrowserUk (Patriarch) on Oct 07, 2011 at 18:41 UTC

    The best tool for formatting fixed length records is pack:

    print pack 'A20 A10 A3', @$_ for ( [ qw[ Name DOB AGE ] ], [ qw[ Name111111 010190 30 ] ], [ qw[ Name222 020280 40 ] ], );; Name DOB AGE Name111111 010190 30 Name222 020280 40

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: print format
by ikegami (Patriarch) on Oct 07, 2011 at 17:41 UTC
    printf("%-10s %-10s %s\n", $name, $dob, $age);
    printf("%-${max_name_length}s %-10s %s\n", $name, $dob, $age);
    printf("%-*s %-10s %s\n", $max_name_length, $name, $dob, $age);
Re: print format
by armstd (Friar) on Oct 07, 2011 at 17:45 UTC

    Your code an output are kind of a mess, which really makes trying to understand what output you're looking for... try using code/blockquotes to clean it up. Also, that's not enough of your code to really understand your current format string. What are all those vars for? What does each one represent?

    Shooting in the dark, I think you're looking for something more like this:

    printf( "%-${name_length}s %-10s %-10d\n", "Name", "DOB", "AGE" ); printf( "%-${name_length}s %-10s %-10d\n", $std_name, $dob, $age );

    --Dave