This answer isn't going to have much to do with perl.
On some Unix systems, you can use /usr/bin/time --verbose command args.... (Be careful -- many shells have a builtin time command, usually with far fewer options.) It has the advantages of telling you the maximum memory used, too. This will not work on Linux (most of the numbers will be zero since they're not recorded.)
On Linux, try reading the file /proc/self/status at various points in processing. Within the END{} block is good, but you might also want to do it earlier in case perl cleans up memory for you before executing the END code.
Probably most portably, run ps -l $$ from within your program (or use whatever flags work on your system and give you good memory-related information.) Example:perl -le '$ps=`ps -v $$`'
If you have a perl built with -DDEBUGGING, you might also try the -m flag to perl itself. You'll need to postprocess that, though. |