On 10/11/06, Karjala <[EMAIL PROTECTED]> wrote:

I run a script called createrss.pl as a cron job every hour which checks
if there are any new stories and if so creates a new feed.rss file

I think this method takes up a lot of RAM and CPU power since it
launches Perl every hour, but I can't think of anything better.

A moderately-powerful machine should be capable of tens of thousands
of launches per hour; one more won't be noticeable. Of course, if your
program takes more than 58 minutes to run, maybe there's room for
improvement. :-)

The other way I thought of (and rejected) was to have the web script
that accepts a new story from the administrator, to also create the RSS
file. But I rejected this because if two people might submit a story at
the same time then the resulting RSS file might only contain one of them.

That sounds like a job for flock(). By locking the file, your process
"installs a traffic light", so to speak. If everybody uses flock()
properly, each process will wait for a green light before editing the
file.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to