kill process when file number reached...

Hello All, I am trying to run a tcpdump and have perl kill the tcpdump once 10 files have been created by the tcpdump. Here is my code, not sure...if my logic is screwy Thanks, system "tcpdump -i bge1 -s0 -w /tmp/file.out -C 1"; sleep 2; while(true){ @array1 = `ls -l /tmp grep files`; $result=@array1+1;