stason.org logo lotus


previous page: CGI-BIN Scripts by Owner Part 1page up: WebMastering & Other Programmingnext page: Html Docs

Answers for some Perl/Cgi questions

 Books
 TULARC
















Answers to some Bothering Questions (Perl + Perl/CGI Mini FAQ):


This Frequently Asked Questions document covers the most bothering Perl/CGI questions along with general Perl topics. If you see some incorrect details or know about better way to do the same thing, please share with me by sending me an email. Thank you!

Table of contents


0. Usenet, Questions and Answers -- The greatest tip.

        Ok this topic is being discussed too many times. Let's try to end it. Many times I was looking for the answers to my questions and one moment before going to scream for a help and going to take people's time to answer them, I thought that while reading my favorite newsgroups and mailing lists I saw people ask the same questions over and over. Nice folks who answered the same questions for a few times went crazy and didn't want to do it again.
        Take a minute to type the magic words www.dejanews.com and beleive me 90% of your questions has been already answered in the past.

What do you get when you do this:

  1. Allow smart folks to answer the new, never answered questions (you are the one who will need it in a 2 weeks)
  2. You get a list of answers, not just one ! So you can pick the best one that suit you
  3. You don't have to wait days before someone answeres you if at all (yep, that happens too)
  4. The answer is immediate (mostly) and lays just a few mouse clicks from you.
  5. You can reuse the answer you have found to request for additional information, these kind of questions are more likely to be answered: I have found an answer that says A, but it doesn't feet my needs because of B, can you please advise me solution C.

So do yourself a favor use www.dejanews.com first , and if you fail to find an answer -- then come and ask your question, and we will gladly help you out.

Another nice page to read is Why Questions go Unanswered?   by Mark-Jason Dominus.

[Back to the TOC]


1. FileLocking Issues. WWW Guestbook Case.


1.1 Locking with flock and modifying the file by opening it only once


1.2 File Locking when flock(3) or lockf(3) is unavailable


1.3 File Locking Issues : Summary

  1. Use flock when more then one program can write on the same time and it has to read/write from the same file
  2. Remember that if you use external locking , program can be stopped in the middle of critical section (User presses a Stop button ) the lockfile isn't getting deleted, so you have to handle that case as well (in case of flock it's not a problem since when file is getting closed it's geitting unlocked as well)
  3. Be carefull when you use scripts someone else wrote, they can be badly written (in the meaning of filelocking and other as well) The script who reported working by many people can fail for you if it's not properly written and you don't want to get things broken, don't you? So this is a second important issue to check when using someone else written programs after taint checking (simple script that interract with your system can delete all you disk if don't worry to untaint the input from the forms....)

    Futher reading: DB Locks Concepts by Don Anderson

  4. [Back to the TOC]

1.4 More locking techniques


[Back to the TOC]

2. File locking Resources (URLS)

These are the pointers to other good resources covering file locking issues:

[Back to the TOC]


2. Securing your CGI scripts. Untainting the form's input (A must thing!)

3. Verify the email addresses

4. How do I pass parameters from one perl program to another thru shell ( solving special shell characters escaping problem)

Understanding the concept

Using the perl Modules

[TOC]


5. Miscellaneous practical Perl5 regexp

http://www.a.com/file/in.html
http://www.a.com/big-dash-dash/in.html
http://www.a.com/file.with.dot/in.html
http://www.a.com/file-dash.dot/in.html
Just to show you that the second snippet is much faster, I have run the Bencmark on both snippets and the results are:
  Benchmark: timing 50000 iterations of try_a, try_b
  try_a: 29 secs (26.31 usr  0.00 sys = 26.31 cpu)
  try_b:  8 secs ( 5.95 usr  0.00 sys =  5.95 cpu)

[Back to the TOC]


6. Debugging CGI scripts easily


7.How to install perl5 modules into a local directory (when you can't become root). Introduction to CPAN.pm

7.1 Installing the modules locally:

7.2 Make your scripts find the modules you have installed:


7.3 Installing new modules that require modules that have been already installed but installed locally:

7.4 Making a fast and easy download/install/upgrade of perl5 modules with CPAN.pm:

Note: All 7.* sections were adopted by iserver.com for their support pages - you might want to check a more clear version of this quick and dirty doc.

[Back to the TOC]


8. Links to other FAQs

[Back to the TOC]


9. Books

[Back to the TOC]








TOP
previous page: CGI-BIN Scripts by Owner Part 1page up: WebMastering & Other Programmingnext page: Html Docs