- 论坛徽章:
- 0
|
我想从一个网页文件中找到这个字符串,然后从中分别取出32和23
<p>High: 32° Low: 23°</p> |
这样写哪里错了呢?
`wget -O - http://weather.yahoo.com/forecast/CHXX0008_c.html > $file`;
open(FILE, $file) or die "Could not open file $file: $!\n";
$leadspace=" "; #spacing before each high low
$trailspace=" "; #spacing after each high low.
$degree=" ℃"; #give me the degree symbol, not everyone has same locale
while(<FILE>){
#get the high temp
(my $high) = /<p>High: (-?\d+)#176; Low: \-?\d+#176;<\/p>/;
#get the low temp
(my $low) = /<p>High: \-?\d+#176; Low: (-?\d+)#176;<\/p>/;
#print the high and low temp for the specified day
if($high=~/\d+/ && $low=~/\d+/ && ++$count<=$day){print "$leadspace$high$degree/$low$degree$trailspace";}
elsif($count>=$day){print "\n"; exit;} #don't keep looking if everything has been found
} |
|
|