Sure, you can create temp files. Just make sure the trigger has permission to write where you want to put it, that there is enough space on the server drive, that you name the file in such a way as to avoid collisions (there is a Perl module for creating temp file names), and that you clean it up afterwards (IIRC, the right module will do that for you).
Keep in mind, though, that if your trigger takes a long time to process it is going to be disruptive, and maybe scary, to users. In that case it may be better to use a daemon to access the file out of the commit loop and have the user fix it rather than try to block it to begin with. (That works if bad files can be tolerated for as long as it takes to fix them. That's a call you need to make.)