Weird Perl Error
Ok I'm having a really weird error in my script (its cut down from 77 lines):
Code:
# Open the file. Code:
[Sun Aug 03 23:13:06 2003] [error] [client 10.10.10.100] Useless use of not in void context at /var/www/cgi-bin/print.pl line 74. |
The problem here is that the if statements are an incorrect use of the =~ and !~ operators. These operators are used with pattern matching (such as m//, s///), not with standard strings.
Consider the following code: Code:
#!/usr/bin/perl Code:
~/perl/happydude> ./tests.pl Code:
# if($IP =~ "10.10*", "192.168*") { Code:
if($IP =~ /^(10\.10|192\.168)/) { Code:
if($IP =~ /^(10\.10|192\.168)/) { Code:
#!/usr/bin/perl Code:
~/perl/happydude> ./tests-fixed.pl |
EDIT: Found the problem.... I had used $ instead of @ for an array... Stupid me. Thankyou.
Thanks to your script and printing the variables in comments my log files are almost clean. The log file now says: Code:
[Mon Aug 04 10:26:58 2003] [error] [client 10.10.10.100] Use of uninitialized value in conca Code:
print "IP: Logged <!-- This is to make Apache happy: $lame -->"; |
That error means the variable $lame is undefined. If lame is supposed to contain something, then find out where it's actually given a value, and verify that the value it's given isn't an undef. If all you need is a quick-fix, then right before line 72, put something that assigns $lame a value if it's not defined. Something like:
Code:
defined($lame) or $lame = ""; |
All times are GMT -5. The time now is 08:33 PM. |