Phoenix.pm: script archive

David Sinck sinck at ip100.corp.quepasa.com
Tue Oct 19 10:58:58 CDT 1999



\_ OK, Call me clueless and uninformed, but could you please explain WHY
\_ these are bad and evil?  I've been using Perl for about a month now, and
\_ they taugh me quite a few tricks.  Some examples of better ways of writing
\_ these scripts would, in theory, help me even more!  :-)

Well, speaking from experience at a previous employer, the wwwboard
script has a number of failings, some of the classic cs 101 "don't do
this" stuff. 

race conditions, manageability, security, etc.

race conditions are particularly bad in wwwboard as there is one
central index file that has *no* file locking on it...it can be
updated by the webserver at any time.  That's cool until two (or more)
people try to update it simultaneously....*poof* corrupted index, lost
articles, global warming, the Four Horsemen.... Oh, wait, skip those
last two.

I've seen race conditions in too much of the perl code I have been
assigned to, and it's reasonably easy to avoid with judicious use of
flock (when it works in your OS...[aix bleh]).  

Manageability is completely different.  Do you need to reproduce the
script entirely to have another board, or can you point it at a config
file and have it be happy?  Can administrators effectively
administrate in the fashion they need to?  Consider not only the end
users (surfers) but the people who have to make the thing be
reasonable.

Security is always important.  Turn on -T and -w.  Think about what
your code could do given worst-case-input.

David




More information about the Phoenix-pm mailing list