MediaW...tPages(3pm)

πŸ“¦
version 0.2.2 Β· 2 versions
  • 0.2.2 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.2.2 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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:

  1. the first element is the article title 🏷️
  2. 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 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 was perl v5.34.0, dated 2022-06-15. go forth and parse those dumps, you absolute icon. periodt. πŸ’…βœ¨πŸŽ€
πŸ“¦ where this page comes from