in reply to malaga's hash/array/search problem

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.

Replies are listed 'Best First'.
Re: Re: malaga's hash/array/search problem
by bent (Scribe) on Jan 18, 2001 at 12:49 UTC
    Also, use taint mode:
    #!/usr/bin/perl -wT
    Taint mode may help your script be more secure by drawing possibly insecure variables to your attention.
      Thank you. I appreciate the help. It took me a while to find this node and the posted replies. I'm still not sure how to find things on this site.
Re: Re: malaga's hash/array/search problem
by malaga (Pilgrim) on Jan 20, 2001 at 05:39 UTC
    Thank you. I appreciate the help. It took me a while to find this node and the posted replies. I'm still not sure how to find things on this site.