ActiveState!

ActivePerl Documentation
Table of Contents

(Usage Statistics)
(about this ver)


* Getting Started
    * Welcome To ActivePerl
    * Release Notes
    * Readme
    * ActivePerl Change Log
* Install Notes
    * Linux
    * Solaris
    * Windows
* ActivePerl Components
    * Overview
    * PPM
    * Windows Specifics
       * OLE Browser
       * PerlScript
       * Perl for ISAPI
       * PerlEZ
* ActivePerl FAQ
    * Introduction
    * Availability & Install
    * Using PPM
    * Docs & Support
    * Windows Specifics
       * Perl for ISAPI
       * Windows 9X/NT/2000
       * Quirks
       * Web Server Config
       * Web programming
       * Programming
       * Modules & Samples
       * Embedding & Extending
       * Using OLE with Perl
* Windows Scripting
    * Active Server Pages
    * Windows Script Host
    * Windows Script Components

Core Perl Documentation


* perl
* perlfaq
* perltoc
* perlbook

* perlsyn
* perldata
* perlop
* perlreftut
* perldsc
* perllol

* perllexwarn
* perldebug

* perlrun
* perlfunc
* perlopentut
* perlvar
* perlsub
* perlmod
* perlpod

* perlstyle
* perlmodlib
* perlmodinstall
* perltrap
* perlport
* perlsec

* perlref
* perlre
* perlform
* perllocale
* perlunicode

* perlboot
* perltoot
* perltootc
* perlobj
* perlbot
* perltie

* perlipc
* perlnumber
* perlfork
* perlthrtut

* perldiag
* perlfaq1
* perlfaq2
* perlfaq3
* perlfaq4
* perlfaq5
* perlfaq6
* perlfaq7
* perlfaq8
* perlfaq9

* perlcompile

* perlembed
* perlxstut
* perlxs
* perlguts
* perlcall
* perlfilter
* perldbmfilter
* perlapi
* perlintern
* perlapio
* perltodo
* perlhack

* perlhist
* perldelta
* perl5005delta
* perl5004delta

* perlamiga
* perlcygwin
* perldos
* perlhpux
* perlmachten
* perlos2
* perlos390
* perlvms
* perlwin32

Pragmas


* attributes
* attrs
* autouse
* base
* blib
* bytes
* charnames
* constant
* diagnostics
* fields
* filetest
* integer
* less
* lib
* locale
* lwpcook
* open
* ops
* overload
* perllocal
* re
* sigtrap
* strict
* subs
* utf8
* vars
* warnings

Libraries


* ActivePerl
    * DocTools
        * TOC
            * RDF
* AnyDBM_File
* Archive
    * Tar
* AutoLoader
* AutoSplit
* B
    * Asmdata
    * Assembler
    * Bblock
    * Bytecode
    * C
    * CC
    * Debug
    * Deparse
    * Disassembler
    * Lint
    * Showlex
    * Stackobj
    * Terse
    * Xref
* Benchmark
* Bundle
    * LWP
* ByteLoader
* Carp
    * Heavy
* CGI
    * Apache
    * Carp
    * Cookie
    * Fast
    * Pretty
    * Push
    * Switch
* Class
    * Struct
* Compress
    * Zlib
* Config
* CPAN
    * FirstTime
    * Nox
* Cwd
* Data
    * Dumper
* DB
* Devel
    * DProf
    * Peek
    * SelfStubber
* Digest
    * HMAC
    * HMAC_MD5
    * HMAC_SHA1
    * MD2
    * MD5
    * SHA1
* DirHandle
* Dumpvalue
* DynaLoader
* English
* Env
* Errno
* Exporter
    * Heavy
* ExtUtils
    * Command
    * Embed
    * Install
    * Installed
    * Liblist
    * MakeMaker
    * Manifest
    * Miniperl
    * Mkbootstrap
    * Mksymlists
    * MM_Cygwin
    * MM_OS2
    * MM_Unix
    * MM_VMS
    * MM_Win32
    * Packlist
    * testlib
* Fatal
* Fcntl
* File
    * Basename
    * CheckTree
    * Compare
    * Copy
    * CounterFile
    * DosGlob
    * Find
    * Glob
    * Listing
    * Path
    * Spec
        * Functions
        * Mac
        * OS2
        * Unix
        * VMS
        * Win32
    * stat
* FileCache
* FileHandle
* FindBin
* Font
    * AFM
* Getopt
    * Long
    * Std
* HTML
    * AsSubs
    * Element
    * Entities
    * Filter
    * Form
    * FormatPS
    * Formatter
    * FormatText
    * HeadParser
    * LinkExtor
    * Parse
    * Parser
    * TokeParser
    * TreeBuilder
* HTTP
    * Cookies
    * Daemon
    * Date
    * Headers
        * Util
    * Message
    * Negotiate
    * Request
        * Common
    * Response
    * Status
* I18N
    * Collate
* IO
    * Dir
    * File
    * Handle
    * Pipe
    * Poll
    * Seekable
    * Select
    * Socket
        * INET
        * UNIX
* IPC
    * Msg
    * Open2
    * Open3
    * Semaphore
    * SysV
* LWP
    * Debug
    * MediaTypes
    * MemberMixin
    * Protocol
    * RobotUA
    * Simple
    * UserAgent
* Math
    * BigFloat
    * BigInt
    * Complex
    * Trig
* MD5
* MIME
    * Base64
    * QuotedPrint
* NDBM_File
* Net
    * Cmd
    * Config
    * Domain
    * DummyInetd
    * FTP
    * hostent
    * libnetFAQ
    * netent
    * Netrc
    * NNTP
    * PH
    * Ping
    * POP3
    * protoent
    * servent
    * SMTP
    * SNPP
    * Time
* O
* ODBM_File
* Opcode
* Pod
    * Checker
    * Find
    * Html
    * InputObjects
    * Man
    * Parser
    * ParseUtils
    * Plainer
    * Select
    * Text
        * Color
        * Termcap
    * Usage
* POSIX
* PPM
    * SOAPClient
    * SOAPServer
* Safe
* SDBM_File
* Search
    * Dict
* SelectSaver
* SelfLoader
* SHA
* Shell
* SOAP
    * Defs
    * Envelope
    * EnvelopeMaker
    * GenericHashSerializer
    * GenericInputStream
    * GenericScalarSerializer
    * Lite
    * OutputStream
    * Packager
    * Parser
    * Transport
        * HTTP
            * Apache
            * CGI
            * Client
            * Server
        * LOCAL
        * MAILTO
        * POP3
        * TCP
    * TypeMapper
* Socket
* Symbol
* Sys
    * Hostname
    * Syslog
* Term
    * ANSIColor
    * Cap
    * Complete
    * ReadLine
* Test
    * Harness
* Text
    * Abbrev
    * ParseWords
    * Soundex
    * Tabs
    * Wrap
* Thread
    * Queue
    * Semaphore
    * Signal
    * Specific
* Tie
    * Array
    * Handle
    * Hash
    * RefHash
    * Scalar
    * SubstrHash
* Time
    * gmtime
    * Local
    * localtime
    * tm
* UDDI
    * Lite
* UNIVERSAL
* URI
    * data
    * Escape
    * file
    * Heuristic
    * ldap
    * URL
    * WithBase
* User
    * grent
    * pwent
* Win32
    * AuthenticateUser
    * ChangeNotify
    * Clipboard
    * Console
    * Event
    * EventLog
    * File
    * FileSecurity
    * Internet
    * IPC
    * Mutex
    * NetAdmin
    * NetResource
    * ODBC
    * OLE
        * Const
        * Enum
        * NEWS
        * NLS
        * TPJ
        * Variant
    * PerfLib
    * Pipe
    * Process
    * Registry
    * Semaphore
    * Service
    * Sound
    * TieRegistry
* Win32API
    * File
    * Net
    * Registry
* WWW
    * RobotRules
        * AnyDBM_File
* XML
    * Element
    * Parser
        * Expat
    * PPD
    * PPMConfig
    * ValidatingElement
* XSLoader

 Netscape::History - object class for accessing Netscape history database


NAME

Netscape::History - object class for accessing Netscape history database


SUPPORTED PLATFORMS

  • Windows
This module is not included with the standard ActivePerl distribution. It is available as a separate download using PPM.

SYNOPSIS

    use Netscape::History;

    $history = new Netscape::History();
    while (defined($url = $history->next_url() ))
    {
    }


DESCRIPTION

The Netscape::History module implements an object class for accessing the history database maintained by the Netscape web browser. The history database keeps a list of all URLs you have visited, and is used by Netscape to change the color of URLs which you have previously visited, for example.

With this module, you can get at the URLs stored in a Netscape history file, delete URLs, and add new ones. With the associated Netscape::HistoryURL module you can access the information which is associated with each URL.

Please Note: the database format for the browser history was changed with Netscape 4. Previously only the time of most recent visit was available; now you can also get at the time of your first visit, the number of visits, the title of the referenced page, and another value.

CONSTRUCTOR

    $history = Netscape::History->new();

This creates a new instance of the Netscape::History object class. You can optionally pass the path to the history database as an argument to the constructor, as in:

    $history = Netscape::History->new('/home/bob/.netscape/history.db');

If you do not specify the file, then the constructor will use:

    $HOME/.netscape/history.db

If the Netscape history database does not exist, a warning message will be generated, and the constructor will return undef.


METHODS

The Netscape::History class implements the following methods:

  • get_url - get a specific URL from your history

  • rewind - reset history database to first URL

  • next_url - get next URL from your history

  • delete_url - remove a URL from your history

  • add_url - add a URL to the history file

  • close - close the history database

Each of the methods is described separately below.

get_url - get a specific URL from your history

    $url = $history->get_url( URL );

This method is used to extract information about a specific URL from your history database.

This method takes a URL (which could be just a text string, or an object of class URI::URL) and returns an instance of Netscape::HistoryURL.

next_url - get the next URL from your history database

    $url = $history->next_url();

This method returns the next URL from your history database. If you want to process all URLs in the database, you should call the rewind method before looping over all URLs.

The URL returned is an instance of the Netscape::HistoryURL class, which works just like an instance of URI::URL, but provides an extra methods, as described in the documentation for Netscape::HistoryURL.

delete_url - remove a URL from the history database

    $history->delete_url($url);

This method is used to remove a URL from your history database. The URL passed can be a simple text string with the URL, or an instance of Netscape::HistoryURL, URI::URL, or any other class which can be rendered into a string.

add_url - add a URL to the history database

    $history->add_url( URL );

This method is used to add a URL to a history database. This might be useful if you are merging information from multiple history databases, for example.

If the URL passed is an instance of Netscape::HistoryURL, then the information available will be stored.

If the URL is specified as a text string, is derived from URI::URL, then a Netscape::HistoryURL will be created with the following:

    LAST   = current time
    FIRST  = current time
    COUNT  = 1
    EXPIRE = 1
    TITLE  = ''

If the EXPIRE field is not set to 1, then it won't appear in Netscape's history window. Not really sure why :-)

rewind - reset internal URL pointer to first URL in history

    $history->rewind();

This method is used to move the history database's internal pointer to the first URL in your history database. You don't need to bother with this if you have just created the object, but it doesn't harm anything if you do.

close - close the history database

    $history->close();

This closes the history database. The destructor will do this automatically for you, so most of time you don't actually have to bother calling this method explicitly. Good programming style says you should though :-)


EXAMPLES

DISPLAY CONTENTS OF HISTORY

The following example illustrates use of this module, and the visit_time() method of the URLs returned. The program will list all URLs visited, along with visit time. The Date::Format module is used to format the visit time.

    #!/usr/bin/perl -w

    use Netscape::History;
    use Date::Format;
    use strict;

    my $history;
    my $url;

    $history = new Netscape::History;
    while (defined($url = $history->next_url() ))
    {
        print "$url :\n";
        print "    First  : ", ctime($url->first_visit_time());
        print "    Last   : ", ctime($url->last_visit_time());
        print "    Count  : ", $url->visit_count(), "\n";
        print "    Expire : ", $url->expire(), "\n";
        print "    Title  : ", $url->title(), "\n";
    }
    $history->close();

MERGE TWO HISTORY FILES

The following example illustrates use of the add_url method to merge two history databases. We read all URLs from history2.db, and merge them into history1.db, overwriting any duplicates.

    $history1 = new Netscape::History("history1.db");
    $history2 = new Netscape::History("history2.db");
    while (defined($url = $history2->next_url() ))
    {
        $history1->add_url($url);
    }
    $history1->close();
    $history2->close();


SEE ALSO

the Netscape::HistoryURL manpage
When you call the next_url method, you are returned instances of this class.

the DB_File manpage
The Netscape history file is just a Berkeley DB File, which we access using the DB_File module. You can use a different DB_File compatible library (such as DB_File::SV185) by running
  use Netscape::History dblib => 'DB_File::SV185'

in which case you are only depending on the specified library and not DB_File.

the URI::URL manpage
The underlying class for the Netscape::HistoryURL manpage, which provides the mechanisms for manipulating URLs.

the Date::Format manpage
Functions for formatting time and date in strings.


AUTHOR

Neil Bowers <neilb@cre.canon.co.uk>, and Richard Taylor <rit@cre.canon.co.uk>.


COPYRIGHT

Copyright (c) 1997-2000 Canon Research Centre Europe. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 Netscape::History - object class for accessing Netscape history database