<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Times New Roman","serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
 /* List Definitions */
 @list l0
        {mso-list-id:1715304810;
        mso-list-type:hybrid;
        mso-list-template-ids:1211384696 134807569 134807577 134807579 134807567 134807577 134807579 134807567 134807577 134807579;}
@list l0:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="2050" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-GB link=blue vlink=purple>

<div class=WordSection1>

<p class=MsoNormal><span style='font-size:11.0pt'>I am writing a new CPAN
module which uses Moose and I want it to comprise of a base module and a set of
optional add-on sub modules which simply add new functionality via Roles.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt'>I want these optional roles
made available to the base module if they are installed.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt'>Anyone got any idea how I can
get my base module to include these optional roles once they are installed ?<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt'>I have toyed with the
following ideas but they all have issues :-<o:p></o:p></span></p>

<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='font-size:11.0pt'><span style='mso-list:Ignore'>1)<span
style='font:7.0pt "Times New Roman"'>      </span></span></span><![endif]><span
style='font-size:11.0pt'>package ‘Whatever’;<br>
use Try::Tiny;<br>
use Moose;<br>
my @optional_roles = qw/ Blah Blah2 /;<br>
foreach my $optional_role ( @optional_roles ) {<br>
try {<br>
    with “Whatever::$optional_role”;<o:p></o:p></span></p>

<p class=MsoListParagraph><span style='font-size:11.0pt'>}; # Ignore errors if
with fails<o:p></o:p></span></p>

<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='font-size:11.0pt'><span style='mso-list:Ignore'>2)<span
style='font:7.0pt "Times New Roman"'>      </span></span></span><![endif]><span
style='font-size:11.0pt'>package ‘Whatever’;<br>
use ExtUtils::Installed;<br>
use Carp;<br>
my $inst = ExtUtils::Installed->new();<br>
my @optional_roles = grep { /Whatever::/ } @{ $inst->modules() };<br>
foreach my $optional_role ( @optional_roles ) {<br>
try {<br>
    with “Whatever::$optional_role”;<br>
} catch {<br>
   croak “Failed to add role $optional_role: $_”;<br>
};<o:p></o:p></span></p>

<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='font-size:11.0pt'><span style='mso-list:Ignore'>3)<span
style='font:7.0pt "Times New Roman"'>      </span></span></span><![endif]><span
style='font-size:11.0pt'>Get the installer for my optional roles to maintain a
file containing the roles installed and refer to that in my base module<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt'>Is there a better way to
handle this ?<o:p></o:p></span></p>

<p class=MsoListParagraph><span style='font-size:11.0pt'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#00539F'>Tony Edwardson<o:p></o:p></span></b></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#00539F'>ForexClear Application Support<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#6B6C6D'>Tel.      +44 (0) 20 7426 7569<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#6B6C6D'>Mob.    +44 (0) 7712 100283<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#6B6C6D'>Email.</span><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <a
href="mailto:Tony.Edwardson@lchclearnet.com"><span style='color:blue'>Tony.Edwardson@lchclearnet.com</span></a><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>ForexClear
Hotline +44 (0) 207 426 7917<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'><img
border=0 width=152 height=26 id="Picture_x0020_1"
src="cid:image001.gif@01CCB974.63D155B0" alt="lchclearnet_logo"><o:p></o:p></span></p>

<p class=MsoNormal><o:p> </o:p></p>

</div>


<p><span style="font-family:'Arial';font-size:8pt;">*************************************************************************************************</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"></span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> </span></p>
<p><span style="font-family:'Arial';font-size:8pt;">This email is intended for the named recipient(s) only. Its contents are confidential and may only be retained by the named recipient(s) and may only be copied or disclosed with the consent of LCH.Clearnet Limited and/or LCH.Clearnet SA.   If you are not an intended recipient please delete this e-mail and notify postmaster@lchclearnet.com.</span></p>
<p><span style="font-family:'Arial';font-size:8pt;">LCH.Clearnet Limited, LCH.Clearnet SA and each other member of the LCH.Clearnet Group accept no liability, including liability for negligence, in respect of any statement in this email.</span></p>
<p><span style="font-family:'Arial';font-size:8pt;">The contents of this email are subject to contract in all cases, and LCH.Clearnet Limited and/or LCH.Clearnet SA makes no contractual commitment save where confirmed by hard copy.  </span></p>
<p><span style="font-family:'Arial';font-size:8pt;">Cet e-mail et toutes les pièces jointes (ci-après le "message") sont confidentiels et établis à l'intention exclusive de ses destinataires. Toute utilisation de ce message non conforme à sa destination, toute diffusion ou toute publication, est interdite, sauf autorisation expresse de LCH.Clearnet Limited et/ou LCH.Clearnet SA. Si ce message vous a été adressé par erreur, merci de le détruire et d'en avertir immédiatement postmaster@lchclearnet.com.</span></p>
<p><span style="font-family:'Arial';font-size:8pt;">LCH.Clearnet Limited, LCH.Clearnet SA et les autres entités du groupe LCH.Clearnet Group, ne peuvent en aucun cas être tenues responsables au titre de ce message à moins qu’il n’ait fait l’objet d’un contrat signé.</span></p>
<p><span style="font-family:'Arial';font-size:8pt;">LCH.Clearnet Limited, Registered Office: Aldgate House, 33 Aldgate High Street, London EC3N 1EA.    Recognised as a Clearing House under the Financial Services & Markets Act 2000. Reg in England No.25932 </span></p>
<p><span style="font-family:'Arial';font-size:8pt;">Telephone: +44 20 7426 7000              Internet: http://www.lchclearnet.com</span></p>
<p><span style="font-family:'Arial';font-size:8pt;">LCH.Clearnet SA, Siège Social, 18 rue du Quatre Septembre, 75002 Paris, Chambre de Compensation conformément au Code Monétaire et Financier.</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"></span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> </span></p>
<p><span style="font-family:'Arial';font-size:8pt;">*************************************************************************************************</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> </span></p></body>

</html>