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.


In reply to Re: Undefined import name priority issue? by hv
in thread Undefined import name priority issue? by sectokia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.