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

Hi, I got a program which reads list of commands from
configuration file and execute it one by one.
I am trying to add -v(verbose) option to my program.
when I simply print the program,
print "Executing $command\n";
As some commands are long and some are short, out put looks bit ugly.
I am just wondering is there any ways to make my output well formatted and pretty???
Updates
Criteria:-
Indentation,
New line after certain number of words,
I better want to avoide using any extra modules.
Thanks
tart

Replies are listed 'Best First'.
Re: format verbose
by roboticus (Chancellor) on Jul 12, 2010 at 06:31 UTC

    tart:

    Short answer: Yes.

    However, since beauty is in the eye of the beholder, and you don't specify what your criteria of pretty, it would be difficult to provide any specific advice.

    I'd suggest using printf and/or format for making your output nice. There are likely a good few modules on CPAN that could help you, but you can search CPAN as well as I can.

    ...roboticus

Re: format verbose
by Anonymous Monk on Jul 12, 2010 at 07:05 UTC
    You could use log4perl for both formatting and verbosity control
    use Log::Log4perl qw(:easy); if( $verbose ){ Log::Log4perl->easy_init($TRACE); } ... TRACE("baring the foo now when the level is $TRACE");