The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


File::Mork - a module to read Mozilla URL history files


    my $mork = File::Mork->new($filename, verbose => 1)
        || die $File::Mork::ERROR."\n";

    foreach my $entry ($mork->entries) {
        while (my($key,$val) = each %$entry) {
            printf ("%14s = %s\n", $key, $val);


This is a module that can read the Mozilla URL history file -- normally $HOME/.mozilla/default/*.slt/history.dat -- and extract the id, url, name, hostname, first visted dat, last visited date and visit count.

To find your history file it might be worth using Mozilla::Backup which has some platform-independent code for finding the profiles of various Mozilla-isms (including Firefox, Camino, K-Meleon, etc.).


new <file> [opts]

Takes a filename and parses that file.

Returns undef on error, setting $File::Mork::Error.

Takes an optional hash of options

  • verbose

    A value up to 3 - defines the level of verbosity

  • age

    A ctime which forces File::Mork to only parse entries later than this.

parse <file>

Internal method to parse the file. Obviously.


Return a list of File::Mork::Entry objects sorted by LastVisitDate.

error <message>

Internal method to set the internal error message

debug <message> <priority>

Internal method to print out a debug message if it's a higher priority than the the current verbosity level.


Extracted from

In Netscape Navigator 1.0 through 4.0, the history.db file was just a Berkeley DBM file. You could trivially bind to it from Perl, and pull out the URLs and last-access time. In Mozilla, this has been replaced with a "Mork" database for which no tools exist.

Let me make it clear that McCusker is a complete barking lunatic. This is just about the stupidest file format I've ever seen.

In brief, let's count its sins:

  • Two different numerical namespaces that overlap.

  • It can't decide what kind of character-quoting syntax to use: Backslash? Hex encoding with dollar-sign?

  • C++ line comments are allowed sometimes, but sometimes // is just a pair of characters in a URL.

  • It goes to all this serious compression effort (two different string-interning hash tables) and then writes out Unicode strings without using UTF-8: writes out the unpacked wchar_t characters!

  • Worse, it hex-encodes each wchar_t with a 3-byte encoding, meaning the file size will be 3x or 6x (depending on whether whchar_t is 2 bytes or 4 bytes.)

  • It masquerades as a "textual" file format when in fact it's just another binary-blob file, except that it represents all its magic numbers in ASCII. It's not human-readable, it's not hand-editable, so the only benefit there is to the fact that it uses short lines and doesn't use binary characters is that it makes the file bigger. Oh wait, my mistake, that isn't actually a benefit at all.

Pure comedy.


Module-ised by Simon Wistow <>

based on

Created: 3-Mar-2004 by Jamie Zawinski, Anonymous, and Jacob Post.


Copyright © 2004 Jamie Zawinski <>


Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.


Might be a bit memory heavy? Could do with an iterator interface.

Can't write Mork dbs.



File::Mork::Entry - an single entry in a mork DB


All methods except new take an optional argument to set them.

new <%opts>

blesses %opts into the class File::Mork::Entry


The internal id of the entry


The url visited


The name of the url visited


The hostname of the url visited


The first time this url was visited as a ctime


The last time this url was visited as a ctime


Whether this URL is hidden from the history list or not


The number of times this url has been visited


The byte order - this is associated with ID number 1.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 490:

Non-ASCII character seen before =encoding in '©'. Assuming CP1252