Hi, It seems that you are not modifying the files so no lock is needed. If to clients are accessing your webserver at the very same moment there are 2 Apache-Processes working so there is not interference between them.
One more sidenote you can read files as a whole using: --------------8<-------------- { local $/ = undef; my var1=''; open( H, "/usr/local/my_setup" ); my $var1 = <H>; close( H ); } --------------8<-------------- Still you should only read the whole content of a file into memory if you really needed to because perl is designed in a way that it will not release the memory any more (this is only relevant for very big files). Tom LUKE wrote: > I have some problem about file handle in mod_perlV2.02 + apache v2.055. > I got some strange result today.And i check the program find > that i forgot to close(filehande). > But this case to bring about some guestion! Will the code influence > each other? When > muti-user visit the same recourse at the same time? > > One clint at A and another in B. > > Q1.How to avoid this situation?? > Need i lock file when i reading file?? > > Q2.what is difference between FLOCK_SH and FLOCK_EX ? > > #!/usr/bin/perl > sub main{ > .... > print Header(); #print http header > .... > my var1=''; > open(H,"/usr/local/my_setup"); > while (<H>){ > $ var1.=$_; #<=======A > } > close(H); > > my $var2; > open(H,"/usr/local/my_page"); > while (<H>){ > $ var2.=$_; #<=======B > } > close(H); > > $var2=~s/SomeText/$var1/igs; > > print $var2; > > return; > } > > main(); > 1;
signature.asc
Description: OpenPGP digital signature