The attached patch moves a plperl sanity check into the correct position. Performing the check in the existing position allows the call to go through to perl first, possibly resulting in a SEGV.
cheers
andrew