Thank you both, merlyn and mdillon, for the help... heh, this is one of the reasons i love perl monks so much!
maybe with some minor modification, it looks like mdillon's code might be just what i was looking for, and seemingly far more efficient than what i proposed.