scalability of perl cgi programs that load text files

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-22-2004
MJL
 
Posts: n/a
Default scalability of perl cgi programs that load text files

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?
Reply With Quote
  #2 (permalink)  
Old 08-22-2004
Skeleton Man
 
Posts: n/a
Default Re: scalability of perl cgi programs that load text files

>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 ?


Reply With Quote
  #3 (permalink)  
Old 08-22-2004
Andy Hassall
 
Posts: n/a
Default Re: scalability of perl cgi programs that load text files

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
Reply With Quote
  #4 (permalink)  
Old 08-22-2004
MJL
 
Posts: n/a
Default Re: scalability of perl cgi programs that load text files

> 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.
Reply With Quote
  #5 (permalink)  
Old 08-22-2004
steve
 
Posts: n/a
Default Re: scalability of perl cgi programs that load text files

"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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:08 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0