in reply to How to do this in Perl ??
I'm sure it can be, except your code isn't exactly easy to break down right now because it's all running together - try putting <CODE></CODE> tags around your script - then someone'll be able to read it and break it down much easier :)
~Brian