It means the doc argument isn't an object,
which is bizarre since you used it to call parse_file. You need to either use the debugger or print ref($doc) and ref($rng), use Data::Dumper, try to see what's going on. Since it's XS, it could get trickier..