Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Problem with HTML::Parser

by tobyink (Canon)
on Mar 11, 2012 at 21:04 UTC ( [id://959020]=note: print w/replies, xml ) Need Help??


in reply to Problem with HTML::Parser

Your my $dbh defines a variable called $dbh which is initially set to undef. And then you call a method ->do on it. But (unless you use autobox, which almost nobody does for production code as it's just too weird) you can't call methods on undef.

I assume you actually want to use the $dbh variable you defined in main. Long term you want to read up about how scoping works in Perl. Short term a solution is to use $::dbh instead of $dbh, and don't use my in front of it. This acts as a global variable, so will be accessible from anywhere in your program. However, global variables are not a good idea, which is why long term you should learn how Perl scoping works.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://959020]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-18 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found