Hello John, Just wanted to say Thank You for ripping my poor little code segment apart the way you did. Some might be offended if you did it to them, but not me... IT MAKES ME A BETTER PERL HACKER! :)
Thanks for opening my eyes to some of my "stupid" code & enlightening me to some new ways of doing things. Since some of my reference material is a couple years old, I welcome the help in getting it right. In the future I'll make it a point to cross reference my books to perldoc to save everybody some time. -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] Wednesday, January 16, 2002, 2:12:13 PM, you wrote: JWK> "K.L. Hayes" wrote: >> >> Hello All, JWK> Hello, >> Could somebody please help me figure out why the following code will >> not write the IP address to a file? >> >> I've verified that the code can find the file, open it & overwrite any >> junk/test data already there with nothing. I've also printed out the >> IP address on the previous page using just the print statement. >> >> <CODE> >> sub pcheck { >> if (param('pwd') eq $pw ) { >> open (CHECK,">${path}dmp.dat") || die "Cannot open dmp.dat: $!"; >> flock (CHECK, 2) if ($flock); JWK> use Fcntl ':flock'; JWK> if ( $flock ) { JWK> flock( CHECK, LOCK_EX ) or die "Cannot lock dmp.dat: $!"; JWK> } >> while (<CHECK>) { JWK> You need this line only if you are reading data IN from a file, not JWK> writing OUT to a file. >> print "$ENV{'REMOTE_ADDR'}"; } JWK> print CHECK "$ENV{'REMOTE_ADDR'}"; >> close (CHECK); >> flock (CHECK, 8) if ($flock); JWK> There is no point in trying to unlock the file now, the close() has JWK> already unlocked it. >> } else { &invalid_info; } JWK> } else { invalid_info() } >> &ad2; JWK> ad2(); JWK> When you call subroutines you shouldn't use an ampersand unless you JWK> understand how and why it behaves differently. JWK> perldoc perlsub >> } >> </CODE> >> >> All help is appreciated. Thank you for your time. JWK> John -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]