Re: File handles in mod_perl

2001-01-24 Thread G.W. Haywood

Hi there,

On Tue, 23 Jan 2001, Barry Veinotte wrote:

> Besides die being a bad thing, is this gentleman right to tell me
> I have to loose my file opens and go with FileHandle ??

Yes and no.  If your Apache child opens files and doesn't close them
you will eventually run out of handles (operating system limit).

It's all in the guide:

http://perl.apache.org/guide

If you read it (all right, if you read it at least a couple of times :)
then you'll be able to baffle your sysadmin.

73,
Ged.





File handles in mod_perl

2001-01-23 Thread Barry Veinotte

Hi Folks,

I received some tips from an admin on a server where I am attempting 
to get a program running under mod_perl using Apache::Registry

All was well for a few weeks, and then data files began to be corrupted 
again... One of the items that was passed on to me was ( as below) regarding
global variables. I am confident that there are no evil globals left, but I don't 
understand ( or don't want to believe ) what he told me about file handles.

> #1. GLOBAL VARIABLES. Most perl programmers neglect to use my for
> every variable type. And even if they can be broken of this bad habit they 
> continue to use global globs (as  used with the open(FI, " Solution? use the FileHandle module;
> use FileHandle;
> 
> then convert code that looks like this:
> open(FI, " my $line=;
> close(FI);
> to this:
> my $fi = new FileHandle " $fi->getline(); # or <$fi>
> $fi->close(); # or ignore it; PERL has garbage  collection...   
> 
> you SHOULD also be able to simply use:
> my *FI;
> but... that looks really silly...

I have read the following in the guide:

::Output of system, exec and open PIPE, "|program" calls will not be sent
::to the browser unless you Perl was configured with sfio. 

I am not sending the output to the browser, but opening sendmail like so
open (MAIL, "|$mail_program") || die "Could Not Open Mail Program: $!"; is
not working. That I can work out. However, is this true about regular opens
on files? 

I use a lot of basic file opens like so:

open(CUSTOMERS,"<$c{globals}{root_dir}/admin/customers.txt") or die "Can't open the 
customers list: $!";

Besides die being a bad thing, is this gentleman right to tell me
I have to loose my file opens and go with FileHandle ??

Any help would be Greatly appreciated. 
Frustration is running high on this one.

Thanks,
Barry