MediaW...tPages(3pm)
π MediaWiki::DumpFile::FastPages π
okay bestie, so this is a page from the User Contributed Perl Documentation, section 3pm, and it's all about MediaWiki::DumpFile::FastPages. no cap, it's literally the fastest way to parse a page dump file and i'm obsessed. π¦
β¨ NAME β¨
MediaWiki::DumpFile::FastPages β Fastest way to parse a page dump file π
πΈ SYNOPSIS πΈ
use MediaWiki::DumpFile::FastPages;
$pages = MediaWiki::DumpFile::FastPages->new($file);
$pages = MediaWiki::DumpFile::FastPages->new(\*FH);
while(($title, $text) = $pages->next) {
print "Title: $title\n";
print "Text: $text\n";
}
like, that's it. that's the whole vibe. π
π ABOUT π
so this one is a subclass of MediaWiki::DumpFile::Pages that sets it up to run in fast mode, and then it uses a custom iterator that straight-up skips the duck-typed MediaWiki::DumpFile::Pages::Page object that fast mode normally hands you β which gives a slight processing speed boost. every little bit counts, periodt. β‘
if you wanna know more about fast mode itself, go read the MediaWiki::DumpFile::Pages documentation. iykyk. π
π§ METHODS π§
fr fr, every single method of MediaWiki::DumpFile::Pages is also available on this subclass. nothing's missing, bestie. π«Ά
new
the constructor for this package, obviously. it gets called with one single parameter: either
- the location of a MediaWiki pages dump file ποΈ, or
- a reference to an already open file handle π
next
returns a two element list where:
- the first element is the article title π·οΈ
- the second element is the article text π
and when there are no more pages available? it returns an empty list. sad but true. π
π AUTHOR π
Tyler Riddle, "<triddle at gmail.com>" π
π BUGS π
please go check out MediaWiki::DumpFile for the deets on how to report bugs in this software. don't be shy. π
π HISTORY π
ngl this one has lore. π«§
this package originally started life as a very limited hack using only XML::LibXML::Reader, and it just sought to text and title nodes in the document. implementing a parser for the full document was a daunting task, so this package just kinda sat there, hoping that other people might find it useful. main character energy but make it patient. π
then: because XML::TreePuller can expose the underlying XML::LibXML::Reader object and sync itself back up after the cursor was moved out from underneath it, the author was able to integrate the logic from this package into the main ::Pages parser. slay. β¨
π COPYRIGHT & LICENSE π
Copyright 2009 "Tyler Riddle".
This program is free software; you can redistribute it and/or modify it under the terms of either:
- the GNU General Public License as published by the Free Software Foundation; or
- the Artistic License.
See http://dev.perl.org/licenses/ for more information.
π quick reminder bestie: this wasperl v5.34.0, dated2022-06-15. go forth and parse those dumps, you absolute icon. periodt. π β¨π
π¦ where this page comes from
- debian bookworm: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms