URI::Bookmarks - Perl module class encapsulating bookmark files |
URI::Bookmarks - Perl module class encapsulating bookmark files
use URI::Bookmarks;
# URI::Bookmarks automagically detects that we're dealing with a # collection of Netscape bookmarks
my $bookmarks = new URI::Bookmarks(file => "$ENV{HOME}/.netscape/bookmarks.html");
my $bookmarks = new URI::Bookmarks(handle => $fh);
my $bookmarks = new URI::Bookmarks(array => \@lines);
# Manipulate $bookmarks using nice tree methods from Tree::DAG_Node, # e.g. delete all bookmarks under $folder: ($bookmarks->name_to_nodes($folder))[0]->unlink_from_mother();
# Then output the new file. print $bookmarks->export('Netscape array');
URI::Bookmarks provides a class for manipulating hierarchical collections of bookmarks. Each entry in the collection is an object of type URI::Bookmark, which is in turn a subclass of Tree::DAG_Node, and hence all standard tree manipulation methods are available (see the documentation for Tree::DAG_Node).
$bookmarks->build_name_lookup();
This method builds an internal hash which maps node names to arrays of nodes which have the corresponding key as their name.
It only needs to be called if you want to rebuild the hash after modifying the bookmark collection in some way; if the hash is needed and has not been built, it will be built automatically.
my $tree_root_node = $bookmarks->tree_root();
$bookmarks->tree_root($new_root);
Returns the current root node of the tree of bookmarks. If the optional parameter is provided, the root node is changed to it.
my @nodes = $bookmarks->name_to_nodes('Cinemas');
Returns an array of all nodes matching the given name.
my $title = $bookmarks->title();
$bookmarks->title($new_title);
Returns the current title of the collection of bookmarks. If the optional parameter is provided, the title is changed to it.
my $origin = $bookmarks->origin(); my $origin_type = $origin{type};
Returns a hash containing information about the origin of the collection of bookmarks.
my @lines = $bookmarks->export('Netscape array');
The interface to the export routines. The examples above show the currently available export types.
$bookmarks->all_URLs();
This method simply returns an array of all the URLs in the collection of bookmarks.
The file
key of new()
might not be safe.
Adam Spiers <adam@spiers.net>
the URI::Bookmarks::* manpage, the URI::Bookmark manpage, the URI::Bookmark::* manpage, perl(1).
URI::Bookmarks - Perl module class encapsulating bookmark files |