Re[2]: Won't write IP address to file
Hello Robert, Duh! Thanks! I knew it was something stupid/simple. I just couldn't figure IT out AND be pulled in 20 other directions at the same time. Sometimes another eye planted in the middle of my forehead would really come in handy... *;) Thanks again for your time! -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] Wednesday, January 16, 2002, 12:32:06 PM, you wrote: HR> It looks like you forgot to specify the file handle when printing. HR> print CHECK "$ENV{'REMOTE_ADDR'}"; } HR> Rob HR> -Original Message- HR> From: K.L. Hayes [mailto:[EMAIL PROTECTED]] HR> Sent: Wednesday, January 16, 2002 6:23 PM HR> To: [EMAIL PROTECTED] HR> Subject: Won't write IP address to file HR> Hello All, HR> Could somebody please help me figure out why the following code will HR> not write the IP address to a file? HR> I've verified that the code can find the file, open it & overwrite any HR> junk/test data already there with nothing. I've also printed out the HR> IP address on the previous page using just the print statement. HR> HR> sub pcheck { HR> if (param('pwd') eq $pw ) { HR> open (CHECK,">${path}dmp.dat") || die "Cannot open dmp.dat: $!"; HR> flock (CHECK, 2) if ($flock); HR> while () { HR> print "$ENV{'REMOTE_ADDR'}"; } HR> close (CHECK); HR> flock (CHECK, 8) if ($flock); HR> } else { &invalid_info; } HR> &ad2; HR> } HR> HR> All help is appreciated. Thank you for your time. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Won't write IP address to file
Hello Robert, After trying your advise it still didn't write to the file. Went & had some dinner... came back & it was obvious... Took the while () statement out & it worked like a charm. Whomever says that your stomach & brain aren't connected... is just wrong... in my case anyway... ;) Posted the solution in case anybody wanted to know. Thanks again! -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] Wednesday, January 16, 2002, 12:32:06 PM, you wrote: HR> It looks like you forgot to specify the file handle when printing. HR> print CHECK "$ENV{'REMOTE_ADDR'}"; } HR> Rob HR> -Original Message- HR> From: K.L. Hayes [mailto:[EMAIL PROTECTED]] HR> Sent: Wednesday, January 16, 2002 6:23 PM HR> To: [EMAIL PROTECTED] HR> Subject: Won't write IP address to file HR> Hello All, HR> Could somebody please help me figure out why the following code will HR> not write the IP address to a file? HR> I've verified that the code can find the file, open it & overwrite any HR> junk/test data already there with nothing. I've also printed out the HR> IP address on the previous page using just the print statement. HR> HR> sub pcheck { HR> if (param('pwd') eq $pw ) { HR> open (CHECK,">${path}dmp.dat") || die "Cannot open dmp.dat: $!"; HR> flock (CHECK, 2) if ($flock); HR> while () { HR> print "$ENV{'REMOTE_ADDR'}"; } HR> close (CHECK); HR> flock (CHECK, 8) if ($flock); HR> } else { &invalid_info; } HR> &ad2; HR> } HR> HR> All help is appreciated. Thank you for your time. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Won't write IP address to file
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. >> >> >> 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 () { 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 >> } >> >> >> All help is appreciated. Thank you for your time. JWK> John -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]