As a first start, that's not too bad. There are several next steps you should take right away:
  1. Turn on warnings with -w
  2. use strict; and fix the problems it reports.
  3. Unbuffer STDOUT via $|++, and
  4. Move the line that prints "Content-type" to the top. (For a good explanation of this and the ones above, see nearly any of merlyn's Web Techniques articles.)

Next, you have a couple of opportunities for improvement.

  1. Use CGI.pm to handle form processing correctly. Form processing is trickier to get right than many book (and code fragments) would have you believe. (Search the Monastery; examples abound.)
  2. Use opendir/readdir/closedir to read the directory from within Perl, rather than forking off ls.
  3. Read up on Perl's join function, and look for a place to place in your code to turn 7 lines into 1.

Then there are some things you can do for extra-credit

  1. Use CGI.pm routines for generating HTML. (Search the Monastery; examples abound.)
  2. look in the docs for what the /o modifier does for regexps

These steps will get your code into good-enough shape that when next you post it, people will be more likely to respond with feedback on your code's correctness.


In reply to Re: malaga's hash/array/search problem by dws
in thread malaga's hash/array/search problem by malaga

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.