in reply to Undefined import name priority issue?
Line 12 of JSON::WebToken is:
use JSON qw(encode_json decode_json);Perl's use statement is shorthand for:
BEGIN { require JSON; JSON->import(qw(encode_json decode_json)); }
.. and the key feature of require is that it loads the module only if it has not already been loaded. It checks that by looking in %INC.
My guess then is that JSON::XS is poking a value into %INC to make it look as if JSON itself has also already been loaded - but failing to define the JSON::import() method.
In the JSON::XS SYNOPSIS section I see:
# Note that JSON version 2.0 and above will automatically use JSON:: +XS # if available, at virtually no speed overhead either, so you should # be able to just: use JSON; # and do the same things, except that you have a pure-perl fallback +now.
.. so I suspect if you change your mylib::json to use JSON instead of use JSON::XS, it will probably make the problem disappear. If my diagnosis is correct, though, I'd call this a bug in JSON::XS.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Undefined import name priority issue?
by sectokia (Friar) on Apr 08, 2025 at 03:31 UTC | |
by afoken (Chancellor) on Apr 08, 2025 at 08:05 UTC | |
by sectokia (Friar) on Apr 08, 2025 at 21:56 UTC | |
by ikegami (Patriarch) on Apr 09, 2025 at 02:25 UTC | |
by hippo (Archbishop) on Apr 08, 2025 at 08:06 UTC |