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

I want to process individual lines from theoutput of ps -aef but the spacing is weird. Is there a way to split it into columns? The spacing seems to be dynamic based on the lengths of the column contents. Thanks!

Replies are listed 'Best First'.
Re: How do i split the output of ps -aef
by AltBlue (Chaplain) on Jan 27, 2001 at 02:56 UTC
    maybe you'd like to take a look to Proc::ProcessTable.

    Note from sintadil: Proc::ProcessTable is platform-dependent and -- at least on the systems with which I'm familiar -- it depends on the existence of a procfs. procfs is strongly deprecated in some Unix versions and doesn't even exist by default in some.

      Proc::ProcessTable is platform-dependent and -- at least on the systems with which I'm familiar -- it depends on the existence of a procfs. procfs is strongly deprecated in some Unix versions and doesn't even exist by default in some.

Re: How do i split the output of ps -aef
by arturo (Vicar) on Jan 25, 2001 at 03:26 UTC

    I take it you mean the output of that command produces fields separated by a variable amount of whitespace. The solution is to split on one-or-more whitespace characters, just do @bits = split /\s+/, $string;

Re: How do i split the output of ps -aef
by Anonymous Monk on Sep 15, 2004 at 02:24 UTC
    ps -aef

    Originally posted as a Categorized Answer.