SPUG: howdy! (and i've got a question)

Charles Mauch cmauch at gmail.com
Sun Jul 31 19:37:05 PDT 2005

>> The next step, which I started working on today was to use 
>> Netscape::Bookmarks to manipulate an existing bookmarks file.
>> It doesn't seem to work as advertised.  It reports..
>> Can't call method "recurse" on an undefined value ...
> Did you "use Netscape::Bookmarks"? 

Yeah, I'll paste some sample code I was trying to use.  I'm still working
on this problem, but I think I found a better solution in my workaround.
I was able to work with XML::XBEL to stash my boomkmark data.  XBEL = XML
Bookmark Exchange Language.  I then simply have firefox import this data on
a regular basis.  It looks like there are a bunch of useful little tools to
play with data in this format too.  For example, I can export my firefox
bookmarks (or a category thereof), and have them automatically sync up to
wordpress for publication on the web.

Here is my original perl snippet which attempted to simply add a bookmark
to a sample blank bookmark file.  It never worked.

,----[ makeabookmark.pl ]
| #!/usr/bin/perl
| use Netscape::Bookmarks
| my $now = "A date";
| my $address = "http://www.perl.org";
| my $username = "Charles Mauch";
| my $title = "Link : from $username at $now";
| my $description = "Link harvested from email from $username";
| my $bookmarks_file = "$ENV{HOME}/testbook.html";
| my $bookmarks = Netscape::Bookmarks->new($bookmarks_file);
| my $link = new Netscape::Bookmarks::Link {
|         TITLE         => $title,
|         DESCRIPTION   => $description,
|         HREF          => 'http://www.perl.org',
|         ADD_DATE      => $epochtime,
|         LAST_VISIT    => $epochtime,
|         LAST_MODIFIED => $epochtime,
|         ALIAS_ID      => 4
| };
| $bookmarks->add($link);
| print $link->as_string;

This snippet results in:

Can't call method "add" on an undefined value at ./makeabookmark.pl line

By removing the $bookmarks->add($link);, I can print out the link itself,
but it doesn't provide the rest of the 'wrapper' material that defines a
bookmark file.  A similar method "works" with XML:XBEL.  So I might be
making an error, but if it works elsewhere I figured it might not be me.

I wanted to get "some output", and then start expanding.  I never got that
far.  This doesn't actually attempt to write to any files, just print out a
properly formatted bookmark string inside a "bookmark" file.

I thought it might be a problem with the modules/cpan on my own machine,
and copied this script to a remote redhat box and installed
Netscape::Bookmarks from cpan.  Same results.

This isn't a huge issue for me after discovering XML::XBEL, but it might be
nice to have this work properly at some poing.

Take it easy

Charles Mauch, [cmauch at gmail.com], Big Time Glue Eater
Every message PGP or S/MIME signed to verify authenticity.
Playing "Hash Pipe" by Weezer (Weezer (Green Album))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/spug-list/attachments/20050801/0096b4fb/attachment.bin

More information about the spug-list mailing list