Hi newbie01,

On Sat, 15 Sep 2012 13:52:53 +1200
newbie01 perl <newbie01.p...@gmail.com> wrote:

> Hi all,
> 
> I have a config file that contains some text as below:
> 
> server01        :/u01/app/oracle/admin/db01/adump              :*.dmp,5
>    :compress         :/bin/gzip
> server01        :/u01/app/oracle/admin/db04/adump             :*.aud,5
>    :remove         :/bin/rm
> server01        :/u01/app/oracle/admin/db06/adump              :*.log,5
>    :remove         :logrotate
> 
> But am wanting to run a script that will take this file as an input
> and produced the following output:
> 
> server01        :/u01/app/oracle/admin/db01/adump              :*.dmp,5
>    :compress       :/bin/gzip
> server01        :/u01/app/oracle/admin/db04/adump              :*.aud,5
>    :remove         :/bin/rm
> server01        :/u01/app/oracle/admin/db06/adump              :*.log,5
>    :remove         :logrotate
> 
> Can anyone advise how is the best way to be able to format the text
> so that they lined up neatly? Perhaps anyone already have a script
> that does what am wanting to do?
> 
> At the moment, am doing it manually reading one line at a time and
> using awk and printf using the max string of each column as the basis
> for the max length of the column for each field. Am wanting to be
> able to use Perl instead.

You can use sprintf in Perl too:

http://perldoc.perl.org/functions/sprintf.html

At least it seems like the logical solution.

For more alternatives, see:

http://perl-begin.org/uses/text-generation/

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

Oh! I wish you could see the look on his face! Actually, I would have also
liked to see the look on his face, but just then I woke up from the dream.
    — The Enemy and how I Helped to Fight It

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to