in reply to Example from perlobj failing?

Its a bad example , but it works with the following tweaks:

The reasons for the "-norequire" are explained in the parent module documentation.

             "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
        -- Dr. Cox, Scrubs

Replies are listed 'Best First'.
Re^2: Example from perlobj failing?
by tobyink (Canon) on Mar 15, 2013 at 06:39 UTC

    Or use the deprecated module base instead, which "just works" in this situation.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
Re^2: Example from perlobj failing?
by HelenCr (Monk) on Mar 15, 2013 at 07:49 UTC

    Chromatic, NetWallah, tobyink: thank you for your explanations. Makes sense.

    For the benefit of PerlMonks users: here is a corrected example, with added printouts, which are cool.

    Many thanks - Helen