|
Hi there,
I tried to implement a call back function using a infinite loop (while(1)) and the fetch method in XML::FeedLite. The following is the structure of my code,
#!/usr/bin/perl
use strict;
use XML::FeedLite;
my $url = 'http://finance.google.com/finance?morenews=10&rating=1&q=NYSE:AGM&output=rss';
my $xfl = XML::FeedLite->new();
while(1) {
open (FIL, ">test000.xml");
FIL->autoflush(1);
$xfl->fetch({$url => sub{
my ($data,$html) = @_;
print FIL $data;
print "KKKKKK\n"; #used to check the callback frequency.
}
});
close FIL;
}
The callback subroutine (the sub{...} within fetch method) should be called only when the feed data changes, but instead, the callback sub gets called quite frequently, which means it is not a callback. Can anyone help?
Thanks a lot in advance!
Min
|