$ top -n1 -c -b [download]
You can parse its output from perl and forget about all the portability issues associated to /proc
In reply to Re: Memory Monitoring by salva in thread Memory Monitoring by steelrose