<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On 2007/03/28, at 17:56, Alceu R. de Freitas Jr. wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Olá monges,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Estou com uma dúvida sobre como evitar estruturas</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">"switch-case" dentro de métodos de uma dada classe.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Por exemplo, se eu tenho uma classe que pode exportar</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">seus valores para diversos formatos, por exemplo:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">sub to_xml() {}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">sub to_html() {}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">sub to_csv() {}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV></BLOCKQUOTE><BR></DIV><DIV>Hrm, um outro email sobre a mesma coisa, um pouco mais elaborado (e testado):</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>&lt;cut&gt;</DIV><DIV>sub to_xml {</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>print 'process xml...', $/;</DIV><DIV>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>sub to_html {</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>print 'process html...', $/;</DIV><DIV>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>my $dispatch = {</DIV><DIV>    'xml'  =&gt; \&amp;to_xml,</DIV><DIV>    'html' =&gt; \&amp;to_html,</DIV><DIV>};</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>foreach (qw(xml html)) {</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>$dispatch-&gt;{$_}-&gt;();</DIV><DIV>}</DIV><DIV>&lt;/cut&gt;</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Espero que ajude!</DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Lucida Grande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>--</DIV><DIV>Igor Sutton</DIV><DIV><A href="mailto:igor.sutton@gmail.com">igor.sutton@gmail.com</A></DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></BODY></HTML>