I'm curious, what is the end result you're try to accomplish? Instead of reinventing the wheel, you could (amongst other possibilities) install the set of nagios plugins. They work on a large number of different platforms. I believe check_vsz (not perl) is their native plugin to monitor what you want, but there's other stuff for nagios people have written, including a fair number of perl scripts.
"This alcoholism thing, I think it's just clever propaganda produced by people who want you to buy more bottled water." -- pedestrianwolf