Here is my sample data from a webpage
<hr>
<h4>This is Second line</h4>
Some Text Here<br>
Some More Text Here<br>
<h4>This is First line</h4>
Mem Capacity : 130.65 MB<br>
Mem Used : 74.52 MB<br>
Mem Available : 56.13 MB<br>
Mem Used Percentage : 57<br>
I am using the following code to extract things like
Mem Capacity : 130.65 MB
Mem Used : 74.52 MB
Mem Available : 56.13 MB
Mem Used Percentage : 57
The code goes like this:
#!/usr/bin/perl
use WWW::Mechanize;
$mech = WWW::Mechanize->new();
$url = 'some url';
$result = $mech->get( $url );
$content = $result->as_string();
print $content;
if($content =~ /Mem Capacity :([\d.]+)/)
{
$value = $1;
print "Memory Capacity $value MB n";
}
I am not getting any output.Can anyone tell me where am i going wrong?
Try this - if($content =~ /Mem\s*Capacity\s*:\s*(\d+(.\d+)?)/i )