also, why does everyone but me just assume in their solution that user will be well-behaved and only enter a single letter? i know we're not writing production code here, but it seems a little odd to me that i was the only one to bother to do 'substr $input, 0, 1'.

Perhaps it is a bleed-over of Perl's DWIM concept. It seems logical (to me, at least) that if the user inputs a string rather than a single character the program should return all lines beginning with that string. But then I imagine it is just as logical to you that the program should only use the first character as the search prefix.

In legitimate production code where we are concerned about how many characters the user inputs, it would probably be better to allow only one character--rather than an entire line--to be input in the first place (don't want to confuse those end-users). And since the OP does say 'letter', we'd also reject any input that isn't one.


In reply to RE: RE: RE: Trying to make a search by takshaka
in thread Trying to make a search by zdog

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.