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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:44:13+00:00 2026-06-12T14:44:13+00:00

I am very new to perl and need some help with extracting a table

  • 0

I am very new to perl and need some help with extracting a table from a web page. I was able to figure out how to get the page to print with perl today. Now I just need to only extract the information in the table which states the temperature.
My current code is:

# perl
use strict;
# use LWP::Simple;
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
$ua->timeout(120);
my $url='http://MyTempSite/';
my $request = new HTTP::Request('GET', $url);
my $response = $ua->request($request);
my $content = $response->content();
print $content;

I am trying to get the temperature readings from this html file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><body    bgcolor="#C0C0C0" text="#000000" vlink="#800080" link="#0000FF"><P><h1>TempTrax Digital Thermometer</h1><BR><table cellpadding=0 cellspacing=0 border=0><TR><TD>Model:</TD><TD width=10 rowspan=7><BR></TD><TD>E4</TD><TR><TD>Manufacturer:</TD><TD>Sensatronics</TD> </TR><TR><TD>Website:</TD><TD><a href="http://www.sensatronics.com">http://www.sensatronics.com</a></TD></TR><TR><TD>Firmware Version:</TD><TD>1.2</TD></TR><TR><TD>Release Date:</TD><TD>December 16, 2003</TD></TR><TR><TD>Serial Number:</TD><TD>EA8E6L0T121</TD></TR><TR><TD>Unit name:</TD><TD>LiveTempMonitor</TD></TR></TABLE><P><h3>Current temperature readings:</h3><p><table><TR><TD width=200>Probe1:</TD><TD> 75.1</TD></TR>
<TR><TD width=200>Probe2:</TD><TD>-99.9</TD></TR>
<TR><TD width=200>Probe3:</TD><TD>-99.9</TD></TR>
<TR><TD width=200>Probe4:</TD><TD>-99.9</TD></TR>
</table></body></html>

How should I go about getting only the information in the “Current temperature readings” table to be pulled? Thank you all ahead of time for taking a look at this.

  • 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-12T14:44:14+00:00Added an answer on June 12, 2026 at 2:44 pm
    use 5.010;
    use strict;
    use warnings;
    
    use XML::LibXML qw( );
    
    my $html = $response->decoded_content( charset => 'none' );
    my $doc  = XML::LibXML->load_html( string => $html );
    my $root = $doc->documentElement();
    my @readings =
       map $_->textContent(),
        $root->findnodes(
           '//table[ position() = 2 ]/tr/td[ position() = 2 ]'
        );
    
    say for @readings;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to perl so I searched for some time but still get
I am very new to perl so please help me out in following I
am very new to Perl and need your help I have a CSV file
I'm very new to perl and trying to figure out how to parse lines
I am very new to Perl and I need to complete a project that
I am getting some very annoying behaviour from my perl cgi scripts running under
I am very new to Perl, so please bear with my simple question: Here
I very new to Python, and fairly new to regex. (I have no Perl
Pretty new to Perl so there may be a very obvious solution here. I'm
Very new to XSL (and XML for that matter), but I need to step

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.