For one thing if the two strings are coming from an outside source you've just given them a means to call an arbitrary method in your code; granted it's not a gaping hole, but that's generally enough to raise the hackles of the security conscious.

That aside, there's also no error checking so if anything does go wrong you merely get the generic "unknown method" error message. Better would be to explicitly validate that it's an allowed method name (either through a dispatch table or hash of valid method names, or at the least through using $obj->can( $method_name ) to check that the method will be callable). If it's not then you can explicitly print your own error message with the two distinct parts of the method name (so you don't have to go diving through the debugger to try and determine if someone tried to call with "xxy4" and "4", or "xxy" and "44", or "xx" and "y44", or . . . ).

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re^3: method invocation syntax at perl by Fletch
in thread method invocation syntax at perl by braveghost

Title:
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, details, 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, summary, 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.