That's a good question. I want to know the answer too. My best guess would be that you can't, because a semaphore must be handled in an un-interupt-able manner. Usually talk of semaphores involves the functions P and V which request and release the semaphore respectivly (usually by incrementing and decrementing a counter.) The problem is the functions must also test the state of the semaphore: increment if 0, decrement if 1. And that has to be done atomically. I think Perl might be too abstracted for that level of control... maybe an Inline C statement could do it though...
Update: Sweet: Shendal points out three different modules that do the work for you. When in doubt... :-)
That's what I get for ignoring my own advice and not searching.