This might be fun for you to add to those two lines:

use Net::Whois::IP ('whoisip_query'); # This module is not installed +automatically with a # Perl installation, so you'll + need to install it # from CPAN in order to be abl +e to use its # whois_ip_query function. use Fcntl (':flock'); if ($userIP) { my $location_of_some_log_file = '/var/logs/my_log_file.log'; open ( my $log_fh, '>> :encoding(UTF-8)', $location_of_some_log_fi +le ) or die "FATAL: Trouble opening '$location_of_some_log_file' for +appending: $!"; flock ( $log_fh, LOCK_EX ); my $ip_whois_response = whoisip_query($userIP); if ($ip_whois_response) { print {$log_fh} "Running whois on IP address '", $userIP, "':\ +n\n"; foreach ( sort keys( %{$ip_whois_response} ) ) { print {$log_fh} "$_ $ip_whois_response->{$_} \n"; } } else { print {$log_fh} qq|Cannot run whois to do an IP lookup, becaus +e no response received when invoking whoisip_query method of Perl mod +ule Net::Whois::IP on IP '$userIP'\n\n|; } close $log_fh or warn "WARNING: Some trouble closing file handle f +or '$location_of_some_log_file': $!"; }
EDITED 4/12/2022 -- corrected "use Net::Whois::IP ('whois_ip_query');" to read "use Net::Whois::IP ('whoisip_query');"

In reply to Re^3: Can my perl scripts get the IP address that called the script? by davebaker
in thread Can my perl scripts get the IP address that called the script? by bartender1382

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.