in reply to Why doesnt it work

You need to use <CODE>tags here.
This won't solve your problem, but it'll make your code readable. Check out Perl Monks Procedures.
setantae@eidosnet.co.uk|setantae|www.setantae.uklinux.net