I want to scan files in a certain Maildir/new to see if the Subject contains "some text".
No, I don't think you do. I think you want to check all newly delivered messages, as they are delivered. You would do that by putting a line like this in your .qmail file (via a custom user template):
...
| condredirect xxx-process headermatch 'Subject: some text'
...
(where xxx is the userid which receives the mail) and then you want to add a ~xxx/.qmail-process file which contains:
| perl script_to_extract_what_you_are_interested_in.pl
Messages are only temporarily in Maildir/new/, and you will miss some messages if a mail client has the folder open, so don't try to do it the way you propose.