Top may not be what you really need. Top is supposed to give a "dynamic real-time view of a running system". On the other hand, "ps selects all processes with the same effective user id (euid=EUID) as the current user and associated with the same terminal as the invoker".
That is why I used the variation "top -b -n 1", so I could grab it as a string. However, Proc::ProcessTable mentioned by the other poster seems to return similar, as a Perl module. I am currently looking into calculating processor and memory usage from it.