Hi guys! I have a problem. I get the error: can't call method "do" on an undefined value

#!/usr/bin/perl -w use strict; package SF; use base "HTML::Parser"; use DBI; my $f_header = 0; my $f_name = 0; my $f_description = 0; sub start { my ($self, $tag, $attr, $attrseq, $origtext) = @_ ; if ($tag eq 'header') { $f_header = 1 }; if ($tag eq 'span' && $attr->{'itemprop'} eq 'name') { $f_name = 1 + }; if ($tag eq 'a' and $f_header = 1) {my $href = $attr->{'href'} }; if ($tag eq 'p' && $attr->{'itemprop'} eq 'description') { $f_desc +ription = 1}; } sub text { my ($self, $text) = @_ ; my $name; my $href; if ($f_name = 1) {my $name = $text} if ($f_description = 1) { my $description = $text; ############## here the error ############# my $dbh->do("INSERT INTO names VALUES('$name', '$href', '$descri +ption')"); ############################################ } } sub end { my ($self, $tag, $origtext) = @_ ; if ($tag eq 'header') { $f_header = 0 } if ($tag eq 'span') { $f_name = 0 } if ($tag eq 'p') { $f_description = 0 } } package main; use strict; use DBI; use LWP::Simple; my $parcer = SF->new; my $dbh = DBI->connect("dbi:SQLite:dbname=/media/DOOMGL/perl/db.sql +t","",""); $dbh->do("DROP TABLE names"); $dbh->do("CREATE TABLE names (name, href, description)"); my $page; for ($page = 1, $page < 3, $page++) { my $url = "http://sourceforge.net/directory/os%3Alinux/freshnes +s%3Arecently-updated/?page=" . "$page"; my $content = get($url); $parcer -> parse($content); }

In reply to Problem with HTML::Parser by artyom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.