I need some help on string parsing in perl. I've an http server that respond with something like this:
<html>
<head><title></title></head><body>
T:17.10;H:32.10
</body></html>
I need to catch the two numbers (in the example 17.10 and 32.10) and put them in two variables that I will use for do some if...then...else cycle.
I'm not so expert in string manipulation and regex, at the moment I'm tring to do this:
my $url = 'http://192.168.25.9';
my $content = get $url;
die "Couldn't get $url" unless defined $content;
my @lines = split /\n/, $content;
$content2 = $lines[2];
$content2 =~ tr/T://d;
$content2 =~ tr/H://d;
my @lines2 = split /;/, $content2;
$tem = $lines2[0];
$hum = $lines2[1];
$tem =~ m{(\d+\.\d+)};
$hum =~ m{(\d+\.\d+)};
but when I print out the line I see something strange: characters missing, space in the line, etc. It seems that I've some strange invisible characters that create confusion.
Could you suggest me a better way for have the two number in two numeric variables?
Thanks Fabio