How To Use GeoIP2 (mmdb) Database With Perl

Published on Author gryzli

This article is the result of my struggles to properly use GeoIP v2 database within Perl.    TL;DR  The FASTEST way to use the database is by installing and utilizing the “MaxMind::DB::Reader::XS” perl module.  And here is a tiny example: use MaxMind::DB::Reader::XS ;  use Data::Dumper;  my $geoip_country = MaxMind::DB::Reader::XS->new( file => ‘/usr/share/GeoIP/GeoIP2-Country.mmdb’ ); print Dumper… Continue reading How To Use GeoIP2 (mmdb) Database With Perl

Decoding \x{ZZZZ} utf8 strings inside perl

Published on Author gryzli

We have some cPanel accounts with Cyrillic language set to default, which makes cPanel to return escaped utf8 messages while you operating with the API.  One of the example messages I was getting , looked like this : \x{437}\x{430}\x{43f}\x{438}\x{441} \x{437}\x{430} \x{434}\x{43e}\x{43c}\x{435}\x{439}\x{43d} \x{201c} some-user-domain.com \x{201d} \x{432}\x{435}\x{447}\x{435} \x{441}\x{44a}\x{449}\x{435} \x{441}\x{442}\x{432}\x{443}\x{432}\x{430}. which is not very eye-friendly.   Using simple… Continue reading Decoding \x{ZZZZ} utf8 strings inside perl

Perl Examples

Published on Author gryzli

The main idea of posting this post is for my own comfort (so I can find these things when I need them). The code examples may not be suitable for direct insertion inside your script.    Find the files location of a perl module perldoc -l Some::Module   Check if perl module is part of… Continue reading Perl Examples

Perl – How To Change Output Based On Execution Context (cron or cli)

Published on Author gryzli

How to log messages based on your run environment ? I find myself often wanting to change my output based on my running environment. Most of the times, while your script is running like cron job, you don’t want your informative messages to go to STDOUT. One of the reasons for that, is that by… Continue reading Perl – How To Change Output Based On Execution Context (cron or cli)

Perl – Web hit function using LWP::UserAgent

Published on Author gryzli

Often I need to issue web hit from a perl code, and re-inventing the wheel with LWP::UserAgent or WWW::Curl::Easy sometimes is too overdose for me.  That’s why I decided to write some semi-universal function called “web_hit()” which could be easily used for issuing web hits.   Important notices: The function always generates POST requests The… Continue reading Perl – Web hit function using LWP::UserAgent