Perl-Sensitive Sunglasses | |
PerlMonks |
Non-empty strings treated as null?!!by watkin (Initiate) |
on Feb 12, 2014 at 23:35 UTC ( [id://1074709]=perlquestion: print w/replies, xml ) | Need Help?? |
watkin has asked for the wisdom of the Perl Monks concerning the following question: Dear perlmonks, As a novice perl programmer, could someone help me solve this seemingly impossible apparent error with my perl interpreter (running on my somewhat dated Linux Mint 14 Nadia system). (I am trying to ban FORUM SPAMMERS from posting to a Drupal content-managed web-site I help administer.) Essentially, the code, listed below erroneously interprets two clearly non-null strings as being null.
The command-line I use is:
The output is:
Reverse (PTR) lookups of 109.163.234.7 and 188.126.75.245 give me respectively edwardsnowden0.torservers.net and 178-137-180-11-broadband.kyivstar.net , which are clearly NON-NULL strings, yet the test in my perl program indictes that those strings are NULL !? Can someone suggets to me how I can fix this apparent problem with perl? I truly need a more efficent way of querying these IP address than with the linux nslookup command-lien utility. Thank you for your attention, watkin Original content restored above by GrandFather Dear perlmonks, Thank you, tangent. I'll try your cleaned up version and let you know how it goes. ... and, thank you, davido. The 'eq' operator in place of '!=' has fixed the problem. I'll be sure to include the use warnings; statement in my perl scripts from now on. I need to quickly test the whole C class IP address range.Whilst use of the perl script will be more efficient than the nslookup linux utility program, what I really need is a means to quickly test the whole IP C class network containing the host (e.g. 136.169.192.25) from which the forum spam was posted (i.e. all IP addresses from 136.169.192.0 to 136.169.192.255) I would like to be able to quickly tell whether or not that network is known to the global DNS/Bind database. If it is not, I can quickly add the whole network (indicated by '136.169.192.%' with the wild '%'character) to the drupal/Mysql 'access' table and set the "access type" field to 'deny'. Havingto test each of the 256 IP addresses in a C Class range would take a a lot of efrort even with the perl script
Back to
Seekers of Perl Wisdom
|
|