okay, I found my mistake after digging through the code again.
my $xml = @_; <br>
should read:
my ($xml) = @_;<br>
*slap*
sorry for wasting your time, and thanks for the hints/tips towards this! Still got alot of worke to do to tidy up the code, think i was just blind not seeing this in the first place.
thanks again :)