Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: What does this code do?

by jwest (Friar)
on Oct 03, 2002 at 20:47 UTC ( #202642=note: print w/replies, xml ) Need Help??


in reply to What does this code do?

I don't think this has anything to do with the position of the item in @EXPORT_OK or @fail.

What the author of the code seems to be interested in is if any of the members of the @_ list appear in @EXPORT_OK or @fail. If one cycles through every memeber of @_ one will appear as the first element. Likewise, if you like, you could check against $EXPORT_OK[-1] and $fail[-1] and get the same result.

Hope this helps!

--jwest



-><- -><- -><- -><- -><-
All things are Perfect
    To every last Flaw
    And bound in accord
         With Eris's Law
 - HBT; The Book of Advice, 1:7

Replies are listed 'Best First'.
Re: Re: What does this code do?
by John M. Dlugosz (Monsignor) on Oct 03, 2002 at 21:09 UTC
    Suppose @EXPORT_OK= qw/foo bar baz/; And the import list is (bar) alone. Just because the whole import list is scanned doesn't mean that if any element matches something in @EXPORT_OK then all elements in @EXPORT_OK are matched!

    In this example, nothing in @_ matches $EXPORT_OK[0] or $EXPORT_OK[-1] for that matter. But something does match something in @EXPORT_OK.

    So... I still don't get it.

      You're absolutely right. I had, apparently mistakenly, assumed that @_ was a superset of the contents of both @EXPORT_OK and @fail, instead of a subset of either.

      Lacking the context of how @_ is being defined, it was an easy assumption to make. Without visibility into the calling code, I'm reticent to hazard another guess.

      I suppose it's not oustide the scope of reason that the code may not reflect the author's intent. In a module this pervasive, however, it's not likely that this is the case.

      --jwest

      -><- -><- -><- -><- -><-
      All things are Perfect
          To every last Flaw
          And bound in accord
               With Eris's Law
       - HBT; The Book of Advice, 1:7
      
        I think it says, "If an argument matches the first entry in @EXPORT_OK, then do the heavy (general) form. Even if said argument (and all arguments) contain no non-alpha characters (including sigels).

        Likewise for the fail array, but I don't know what that's for yet.

        Module buggy? Well, calling export_to_level was reportedly buggy a year ago, so who knows? If it mistakenly runs the general form, it will not malfunction, so a mistake in this logic could indeed go unnoticed.

        I'm wondering if it's to support a feature that got dropped. Maybe the first entry in @EXPORT_OK was to mean something special?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://202642]
help
Chatterbox?
[erix]: /hehehe
[marto]: LanX yesterday I found out about Gish gallop tactic
[marto]: "Eugenie Scott, executive director of the National Center for Science Education, dubbed this approach the Gish gallop, describing it as "where the creationist is allowed to run on for 45 minutes or an hour, spewing forth torrents of error that the
[marto]: evolutionist hasn't a prayer of refuting in the format of a debate." She also criticized Gish for failing to answer objections raised by his opponents"
[erix]: one would hope evolutionists haven't any prayers anyway

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-07-28 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (431 votes). Check out past polls.