This is a discussion on scalability of perl cgi programs that load text files within the PHP Language forums, part of the PHP Programming Forums category; Suppose you have a perl program that is called by a web page to generate another web page. The program ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Suppose you have a perl program that is called by a web page to
generate another web page. The program is written to load data from a text file on the server and make certain substitutions in the loaded text prior to the output of html. If one user is on the site, it should not be a problem. If many users try to access it nearly simultaneously, will it be a problem? example: file: text.txt I am <adjective>. file: process.perl .... open INPUT, "./text".".txt"; @list = <INPUT>; close INPUT; foreach(@list) { s/<adjective>/stupid/g; } .... What happens here when a second user causes the program to run when the first user is at the point where the text file is opened and not yet closed? |
|
|||
|
>Suppose you have a perl program that is called by a web page to
>generate another web page. The program is written to load data from a >text file on the server and make certain substitutions in the loaded >text prior to the output of html. >If one user is on the site, it should not be a problem. If many users >try to access it nearly simultaneously, will it be a problem? That's what file locking is designed for.. look into flock().. Regards, Chris P.S. You do realise this a PHP group ? |
|
|||
|
On 21 Aug 2004 22:33:08 -0700, mail@affordablemedicalsoftware.com (MJL) wrote:
>Suppose you have a perl program that is called by a web page to >generate another web page. Suppose you post this Perl program to a PHP newsgroup... what is the expected result? :-) Try comp.lang.perl.misc. > The program is written to load data from a >text file on the server and make certain substitutions in the loaded >text prior to the output of html. > >If one user is on the site, it should not be a problem. If many users >try to access it nearly simultaneously, will it be a problem? Not if it's read-only. If it's updated, then yes, you'll have multiple processes stomping on each other's data, in which case you need to put locking around it, or better, use a database, as concurrent access is one of the several main reasons you'd use a database over a flat file. >example: > >open INPUT, "./text".".txt"; You probably want to be specifying a filemode here - assuming you just want 'r' (read-only). >What happens here when a second user causes the program to run when >the first user is at the point where the text file is opened and not >yet closed? Presumably operating-system dependent, but it would have to be a pretty duff operating system to disallow read-only access to multiple processes. -- Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool |
|
|||
|
> Regards,
> Chris > > P.S. You do realise this a PHP group ? Oh, man. I am so embarrassed. Sorry. I have been so entangled in playing with code in the two languages this weekend that I really screwed up and posted to the wrong group. My perl script is generating HTML and PHP. Sorry again. |
|
|||
|
"MJL" wrote:
> Suppose you have a perl program that is called by a web page to > generate another web page. The program is written to load data from a > text file on the server and make certain substitutions in the loaded > text prior to the output of html. > > If one user is on the site, it should not be a problem. If many users > try to access it nearly simultaneously, will it be a problem? > > example: > > file: text.txt > > I am <adjective>. > > file: process.perl > > .... > open INPUT, "./text".".txt"; > @list = <INPUT>; > close INPUT; > foreach(@list) > { > s/<adjective>/stupid/g; > } > .... > > What happens here when a second user causes the program to run when > the first user is at the point where the text file is opened and not > yet closed? This is a php newsgroup. Try a perl newsgroup for better coverage. -- http://www.dbForumz.com/ This article was posted by author's request Articles individually checked for conformance to usenet standards Topic URL: http://www.dbForumz.com/PHP-scalabil...ict142045.html Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=475202 |