To me, this is a classic “XY problem.” You describe your present approach, not the outcome that you need to achieve.
If at all possible, you need to be able to tell the program that you are shelling-out to that you only want for it to return so-many rows. (Or, might you be able to do the job within the Perl program?) It is wasteful at best, and uncertain/unstable at worst, to rely upon “killing” a child-process that is merely doing what you told it to do. If it is at all feasible to change the target program to support your actual requirements (through, say, the addition of a new command-line parameter), then I strongly counsel you to do so. This is your best and most-certain bet.