Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

"Could you try explaining this again? In particular, what is the code outside of Moo that causes $_ to exhibit this problem? It probably doesn't help that I'm not clear on how 'undef' ends up in @roles (is the code that does that shown anywhere in this thread?)."

Moo::Role loops through the list of roles with a for loop, using the default loop variable, global $_. (Or rather it did, as this is now fixed.)

In for loops, the loop variable is an alias into the array. If you assign to it, the original array is altered. Thus within that loop, if $_ were assigned to, it would alter the list of roles.

Now, what happens within the loop? The role modules get required. And thus any modules that the role modules use get loaded too. And in all that code that gets loaded, somewhere, undef gets assigned to global $_. (And no, I don't know exactly where... Spreadsheet::WriteExcel has a number of dependencies.)

That's how undef gets into @roles.

"I'm also unclear how the 'uninitialized' warning causes the Role::Tiny module to fail (leading to a "Compilation failed") without producing an error message."

Role::Tiny has:

use warnings FATAL => 'all';
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

In reply to Re^9: Moo and Spreadsheet::ParseExcel (explain?) by tobyink
in thread Moo and Spreadsheet::ParseExcel by karlgoethebier

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (3)
    As of 2018-05-27 23:50 GMT
    Find Nodes?
      Voting Booth?