Then that someone ignored the instructions, unless there is a universe where time runs backwards (Red Dwarf not withstanding;), hence Garbage In, Garbage Out.

The point is that if you want to allow for the possiblity that someone using the program doesn't understand the difference between "Enter start date" and "Enter end date", and you wish to have the program perform remedial action, then that is your perrogative, but the last thing you need to do is mess with the while loop.

Simply add

die 'Dont be silly' unless Date_Cmp( $start, $end ) < 0;

after the input.

Of course, they could also type ^C at the first prompt and they fail to get the correct output. Is that the programs fault?

Or they might redirect the output to the nul device. Should the program attempt to trap and handle that situation?

Don't think I'm getting on your case, but the code was offered as how I would code it, as requested in the original post. If you or the OP, or anyone else wish to use it as is, that's fine. If you wish to add additional error checking to cater for the potential idiot user, that's fine too. You entirely welcome to ignore the code completely too.

Again, that tirade isn't aimed at you personally, but is a general comment against third-party, hyper-pedantic critisism and "corrections" of code offered by a 2nd party to a first party with the sole intent of being of assistance to the 1st party.

The keyword in that legalistic gobbaldy gook is "assistance". Code posted here is intended to be of assistance, an example, a pointer in (hopefully a right) direction. As such, it comes without warrenty or support and should be viewed and used in that light.

The expectation that the code will be 100% perfect, tailored exactly to the OP's needs, environment or skill levels is not just optimistic, it is dangerous. If that expectation is allowed to take hold, grow and flourish, then this site would die. Who would bother to spend their personal time trying to produce such code for no reward beyond "Personal satisfaction + XP", which in my opinion is worth just a little less than personal satisfaction alone.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
Wanted!


In reply to Re: Re: Re: Re: Re: Critique by BrowserUk
in thread Critique by phenom

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.