I am currently trying to extract and break up information for a Web page that contains temperature readings. I am a complete beginner when it comes to Perl and I’m having some trouble. The page I’m trying to extract information from is: http://temptrax.itworks.com/temp.
So far I was able to figure out how to get the page and break up the four temperature readings into four lines using split. Here is what I was able to come up with so far:
#!/usr/bin/perl
use warnings;
use LWP::Simple;
use v5.10.1;
my $content = get('http://temptrax.itworks.com/temp');
my @split = split ('Probe',$content);
foreach my $split(@split){
$split =~ s/'Probe''|'/ /g;
print $split . "\n";
}
The next step that I’m having trouble with is separating the four temperature reading using case statements. I don’t quite understand how to do them. I want to be able to get a readings for each each probe separately when giving a specific number 1-4. What’s the best way to do this?
By parsing directly into a hash, we can simply iterate over the keys, or do whatever else one would want to do with the data structure. No
caseneeded. BTW theSwitchmodule is deprecated and really should not be used.The regex can be explained (and even replaced) by this: