AnyDat...:Weblog(3pm)

πŸ’– AnyDat...:Weblog(3pm) β€” the one where your webserver logs become a whole vibe πŸ’–

okay bestie, sit down, hydrate, because this is the Perl manual page for AnyData::Format::Weblog and it is genuinely iconic. it's a plug-in, it lives in the User Contributed Perl Documentation section, and it's about to make your HTTPD logs feel like a main character. πŸ¦‹


✨ NAME ✨

AnyData::Format::Weblog β€” tiedhash & DBI/SQL access to HTTPD Logs. no cap, that's the whole deal: you get to poke at your web server's log files with hashes or with SQL. pick your fighter. πŸ’…


🌸 SYNOPSIS 🌸

first option, the tied-hash girly route:

use AnyData;
my $weblog = adTie( 'Weblog', $filename );
while (my $hit = each %$weblog) {
   print $hit->{remotehost},"\n" if $hit->{request} =~ /mypage.html/;
}
# ... other tied hash operations
literally just each over it like any other hash. the logs become little records and you go fishing. πŸŽ€

OR, the other option, if you're feeling database-coded today:

use DBI
my $dbh = DBI->connect('dbi:AnyData:');
$dbh->func('hits','Weblog','access_log','ad_catalog');
my $hits = $dbh->selectall_arrayref( qq{
    SELECT remotehost FROM hits WHERE request LIKE '%mypage.html%'
});
# ... other DBI/SQL read operations
yes you really do just SELECT your way through an access log. it's giving database but make it a text file. πŸ”₯

πŸ’œ DESCRIPTION πŸ’œ

so what is this? it's a plug-in format parser for the AnyData and DBD::AnyData modules. 🫢 that means you can get read access to Common Log Format files β€” the web server log files, like NCSA or Apache β€” either through tied hashes or arrays, or through SQL database queries. your call, both slay.

the fieldnames come straight from the W3 definitions, which live at:

http://www.w3.org/Daemon/User/Config/Logging.html#common-logfile-format

and here they are, in order, no notes:

 remotehost
 usernname
 authuser
 date
 request
 status
 bytes
quick heads up bestie: that second one is spelled usernname in the source, with the extra n, and i am NOT fixing it because the rule is the rule. type it exactly. ✨

plus there are two extra bonus fields that may show up if your logfiles are in extended format:

 referer
 client

extra fields? in my logfile? it's more likely than you think. πŸ’€

and now the sad part 😭 β€” this module does not currently support writing to weblog files. read-only, bestie. look, don't touch.

for the rest of the deets, go read the docs for AnyData.pm and DBD::AnyData.pm. they know things. πŸ“š


copyright 2000, Jeff Zucker <jeff@vpservices.com> all rights reserved. respect the icon, he built this. 🫑


that's the whole page!! go parse some logs, you're doing amazing sweetie πŸ’–πŸ¦‹πŸŒΈ

this lil writeup is from perl v5.36.0, dated 2023-08-06 β€” mwah, bye!! πŸ’…βœ¨

πŸ“¦ where this page comes from