<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=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<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
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Times New Roman","serif";
        color:#1F497D;}
.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;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</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;color:#1F497D'>Thanks – that looks
like just what I need<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;color:#1F497D'><o:p> </o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> jan.henning@thorsen.pm
[mailto:jan.henning@thorsen.pm] <b>On Behalf Of </b>Jan Henning Thorsen<br>
<b>Sent:</b> 13 December 2011 09:23<br>
<b>To:</b> Tony Edwardson<br>
<b>Cc:</b> miltonkeynes-pm@pm.org<br>
<b>Subject:</b> Re: Adding roles to a CPAN module<o:p></o:p></span></p>

</div>

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

<p class=MsoNormal>I suggest using Module::Find:<o:p></o:p></p>

<div>

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

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>  use Module::Find 'usesub';<o:p></o:p></p>

<div>

<p class=MsoNormal>  with usesub "Whatever::Plugins";<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'>}<br>
<br>
That way you can see if the roles has conflicts. Adding one-and-one will not
detect conflicts in the same way.<o:p></o:p></p>

<div>

<p class=MsoNormal>2011/12/13 Tony Edwardson <<a
href="mailto:Tony.Edwardson@lchclearnet.com">Tony.Edwardson@lchclearnet.com</a>><o:p></o:p></p>

<div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><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.</span><o:p></o:p></p>

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

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><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 ?</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt'> </span><o:p></o:p></p>

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

<p><span style='font-size:11.0pt'>1)</span><span style='font-size:7.0pt'>     
</span><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”;</span><o:p></o:p></p>

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

<p><span style='font-size:11.0pt'>2)</span><span style='font-size:7.0pt'>     
</span><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>
};</span><o:p></o:p></p>

<p><span style='font-size:11.0pt'>3)</span><span style='font-size:7.0pt'>     
</span><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</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt'> </span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt'>Is there a better way to handle this ?</span><o:p></o:p></p>

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

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt'> </span><o:p></o:p></p>

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

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

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#6B6C6D'>Tel.     
<a href="tel:%2B44%20%280%29%2020%207426%207569" target="_blank">+44 (0) 20
7426 7569</a></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#6B6C6D'>Mob.   
<a href="tel:%2B44%20%280%29%207712%20100283" target="_blank">+44 (0) 7712
100283</a></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><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" target="_blank">Tony.Edwardson@lchclearnet.com</a></span><o:p></o:p></p>

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

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:10.0pt;font-family:"Arial","sans-serif"'>ForexClear Hotline <a
href="tel:%2B44%20%280%29%20207%20426%207917" target="_blank">+44 (0) 207 426
7917</a></span><o:p></o:p></p>

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

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span
lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>Error!
Filename not specified.</span></b><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

</div>

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

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

<p><span style='font-size:8.0pt;font-family:"Arial","sans-serif"'>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 <a
href="mailto:postmaster@lchclearnet.com" target="_blank">postmaster@lchclearnet.com</a>.</span><o:p></o:p></p>

<p><span style='font-size:8.0pt;font-family:"Arial","sans-serif"'>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><o:p></o:p></p>

<p><span style='font-size:8.0pt;font-family:"Arial","sans-serif"'>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><o:p></o:p></p>

<p><span style='font-size:8.0pt;font-family:"Arial","sans-serif"'>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 <a
href="mailto:postmaster@lchclearnet.com" target="_blank">postmaster@lchclearnet.com</a>.</span><o:p></o:p></p>

<p><span style='font-size:8.0pt;font-family:"Arial","sans-serif"'>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><o:p></o:p></p>

<p><span style='font-size:8.0pt;font-family:"Arial","sans-serif"'>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><o:p></o:p></p>

<p><span style='font-size:8.0pt;font-family:"Arial","sans-serif"'>Telephone: <a
href="tel:%2B44%2020%207426%207000" target="_blank">+44 20 7426 7000</a>
Internet: <a href="http://www.lchclearnet.com" target="_blank">http://www.lchclearnet.com</a></span><o:p></o:p></p>

<p><span style='font-size:8.0pt;font-family:"Arial","sans-serif"'>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><o:p></o:p></p>

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

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

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

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
MiltonKeynes-pm mailing list<br>
<a href="mailto:MiltonKeynes-pm@pm.org">MiltonKeynes-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/miltonkeynes-pm" target="_blank">http://mail.pm.org/mailman/listinfo/miltonkeynes-pm</a><o:p></o:p></p>

</div>

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

</div>

</div>

</div>

</body>

</html>