Perlfect Solutions
 

[Perlfect-search] FIX: save title correctly

Cameron Moore lists@toad.bitstreet.net
Thu, 25 Oct 2001 13:14:14 -0500
Fixed another bug.  :-p

In indexer.pl, I was jacking around with index_file() and added some
code containing:

  $url =~ /.+\.(.*)$/;

Well, that ended up breaking the title saving code in record_desc().
The offending code starts at line 375 in CVS and looks like:

  ${$buffer} =~ m/<TITLE>(.*?)<\/TITLE>/is;
  $title = $1;

The problem lies in setting $title = $1 without checking to see where it
came from.  If the TITLE pattern doesn't match, $1 is left alone...which
means it will remain whatever it was prior to it the current pattern.
In this case, $1 = 'pdf'.  When the TITLE pattern doesn't catch
anything, $title is set to 'pdf'!  Yikes!  This doesn't effect most HTML
files because they almost always have a title specified, but it will
break for any HTML files that don't.  The fix is to do this:

  ($title) = ${$buffer} =~ m/<TITLE>(.*?)<\/TITLE>/is;

$1 is used in a few other places that I don't think are affected by this
problem, but the above fix should take care of this issue.

BTW, is there anonymous pserver CVS access?  I couldn't find any mention
of it.  Thanks
-- 
Cameron Moore
/ I think you can be an honest person and lie about any number \
\    of things.  -- Dan Rather talking about President Clinton /