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 8465743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:08:13+00:00 2026-06-10T15:08:13+00:00

I wrote a simple perl script but i am getting this runtime error: Can’t

  • 0

I wrote a simple perl script but i am getting this runtime error:

Can’t call method “get_tag” on an undefined value at Parser.pl line 6

Below is my code:

#!usr/bin/perl
use HTML::TokeParser
my $p=HTML::TokeParser->new('bad.html');
while (my $token=$p->get_tag('a')){
my $url=$token->[1]{href};
print "$url\n";
}

I have placed a file bad.html under the same directory of this perl program.
Below is the code for bad.html

<html><body>
<a href="https://www.Google.com">Google</a>
<a href="https://www.yahoo.com">Yahoo</a>
</body></html>

Please help me on the error in running my perl code.

  • 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-06-10T15:08:15+00:00Added an answer on June 10, 2026 at 3:08 pm

    The problem of not using:

    use strict;
    use warnings;
    

    They save you hours! You missed a ; in the line use HTML::TokeParser.

    You could write the script in a better way:

    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    
    use HTML::TokeParser;
    
    my $p = HTML::TokeParser->new('bad.html');
    while ( my $token = $p->get_tag('a') ) {
        my $url = $token->[1]{href};
        print "$url\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wrote a very simple perl tk script to read a huge text
I wrote the following Perl script (below) in order to create simple XML file.
I wrote a very simple Perl script that contains the following line. my $q_it
I wrote a very simple perl script, and now I want to make it
I wrote a simple shell script to get the version of Perl modules installed
I wrote a simple XML file and a DTD file including an entity, but
I'm trying write a simple perl script that reads some fields from a password
So I wrote a simple html 1.0 server, and I have some perl scripts
I wrote a simple test daemon using Proc::Daemon . Here is the daemon: #!/usr/bin/perl
I am trying to translate a python script to perl but currently stuck at

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.