I have a perl script that calls external executables using system(). I would like to measure the CPU seconds taken by these external programs. Ideally, I would like
system()
You've tested the command with bash, but you passed it to sh.
bash
sh
system("time (ls)")
is short for
system("/bin/sh", "-c", "time (ls)")
but you want
system("/bin/bash", "-c", "time (ls)")