Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6327481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:17:14+00:00 2026-05-24T17:17:14+00:00

I am getting the error Undefined subroutine &main::1 called at /usr/local/lib/perl/5.10.0/HTML/Parser.pm line 102. Here

  • 0

I am getting the error

Undefined subroutine &main::1 called at /usr/local/lib/perl/5.10.0/HTML/Parser.pm line 102.

Here is my code

#open (IN,  "<", "foo.html") or die "can't open source file: $!";

my $p = HTML::Parser->new( api_version => 3,
            start_h => [&start, "tagname, attr, text"],
            text_h  => [&text,  "text"],
            default_h   => [sub { print OUT shift }, "text"],
        );
$p->utf8_mode;
$p->empty_element_tags;
$p->ignore_elements(qw(br));

$p->parse_file("foo.html") or die "parsing failed: $!";
#while (<IN>) {
#    $p->parse($_) || die "parsing failed: $!";
#}
#$p->eof;
#close IN;

As you can see in the commented out parts I have also tried directly opening and calling parse (with equally little luck).

The file does open fine.

Parser.pm line 102 which is error mentions is the parse_file subroutine, specifically the line calling ->parse

I have no clue where parse is, it is not in HTML::Parser nor did I find it in HTML::Entities the only dependency HTML::Parser has. =/ I am afraid I am lost at this point, the deepest magics of PERL are still a mystery to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:17:15+00:00Added an answer on May 24, 2026 at 5:17 pm

    Try using \&start and \&text:

    my $p = HTML::Parser->new( api_version => 3,
            start_h => [\&start, "tagname, attr, text"],
            text_h  => [\&text,  "text"],
            default_h   => [sub { print OUT shift }, "text"],
        );
    

    Otherwise you are passing the result of calling start() and text(), not references to them as subs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a syntax error (undefined line 1 test.js) in Firefox 3 when I
I'm getting this error : undefined local variable or method sessions_path' for #<#:0x2db44c8> when
I'm getting the following error: undefined method `id' for #<Array:0x00000101ff0b70> On this line: <%=
I'm getting this error: undefined method `post_comments_path' for #<#<Class:0x1052a6e98>:0x1052a4be8> Extracted source (around line #27):
Trying to compile a iPhone/iPad application with SDK3.2 and am getting this error: Undefined
I am getting JQUERY undefined error. Do you have any idea (code below). <%@
I am getting the following error: Microsoft JScript runtime error: 'Sys' is undefined While
I am getting a Microsoft JScript runtime error: 'Sys' is undefined error on one
I'm getting an Undefined Instruction error while running an embedded system, no coprocessor, no
Why am I getting an undefined label error in following code? (I am leaving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.