develooper Front page | perl.libwww | Postings from December 2000

Why the do statement generate error?

Thread Next
Ivan C Myrvold
December 19, 2000 11:13
Why the do statement generate error?
Message ID:
The code snippet I got a couple of days ago was really great, but I still have some problem with it. It generates an error:

my $response = do {
	my $handle = IO::File->new(">tvschedule.html");
	$ua->request(HTTP::Request->new(GET=>$url),sub{ print $handle $_[0]; $p->parse($_[0]);});

# Expand all image URLs to absolute ones
my $base = $response->base;   ##### this is line 34

This gives the following error:

syntax error at /Users/ivan/bin/fmn line 34, near "my "
Execution of /Users/ivan/bin/filmnet aborted due to compilation errors.

If I on the other hand replace the "do" block with:

$response = $ua->request(HTTP::Request->new(GET => $url), sub {$p->parse($_[0])});

then the program runs fine.

Is there a difference in the $response returned by these two cases?


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About