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

Yitzchak Scott-Thoennes sthoenna at efn.org
Sun Jul 31 22:30:56 PDT 2005


On Sun, Jul 31, 2005 at 10:22:05PM -0700, DeRykus, Charles E wrote:
>  
> 
> > ,----[ makeabookmark.pl ]
> > | #!/usr/bin/perl
> > | use Netscape::Bookmarks
> > | my $now = "A date";

Now there's a lovely case for "use strict;".  That's parsed as

   use Netscape::Bookmarks my $now = "A date";

which is more or less:

   BEGIN {
      require Netscape::Bookmarks;
      Netscape::Bookmarks::->import(my $now = "A date");
   }

so the missing semicolon doesn't throw an error, but prevents $now
from being defined outside the implicit BEGIN; you do get a "Use of
uninitialized value" when you try to use $now later under
warnings/diagnostics, but with use strict it becomes a fatal error.

> > | 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)
>           or die "couldn't find/open $bookmarks_file";       #| just in
> case....
> 
>       The constructor probably returns undef and so the bookmarks object
> will have a short, painful life ...:)

I'd add $! just in case the constructor leaves it set to something
diagnostically useful.



More information about the spug-list mailing list