This is slightly off-topic but I can't resist expressing my dislike for this post to which I'm replying. Writing a bogus routine that seems to do what's expected, even with test cases, and without strong indication that it's just a hoax as first reply to a serious question is just despicable. It contributes nothing but confusion. Sure, cute code can be fun but it should be in the right place. The first reply to a serious question is definately not the right place. Making it look like a serious reply doesn't make it any better. If one truly does want to contribute one would also include an explanation of how the cute code works. Otherwise it's just showoff.

The smilie and the "sometimes" hints you about it being bogus, but the "sometimes" can easily be interpreted as "it tries to make a qualified guess but sometimes fails" (in contrast of long, slow but working algorithms), especially since it provides several test cases. I can't blame any new Perl programmer that think "hey, cool, yet another guru trick" when looking at the above routine with all its, to the new Perler, new elements: %_, $%, and ~~. (Compare with the fairly common my $file = do { local (@ARGV, $/) = $filename; <> };, except that works.)

To broaden this post I'd like to encourage everyone to follow Ovid's (I believe, can't find the reference now) example of waiting a while for the question to be answered before posting cute solutions or getting into side-track discussions.

What scares me though is that the post has a fairly high reputation in comparison to the replies which provide solutions that actually work.

Just my thoughts,
ihb


In reply to Re: Re: Percentages to Fractions by ihb
in thread Percentages to Fractions by David Caughell

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.