fix reference_root code to work on perl 5.12