in reply to Waiting for a response
You may also consider exiting the foreach right after finding the HEAD tag to avoid looping after you know the answer.
UPDATE: Note that if ($response->is_success) is true you successfuly "got" the requested page, so unless you need some to inspect the content to take some action, you probably don't really need to take the effort to through the content. (also consider what happens if they go and make a change and lowercase the HEAD tag on you :)sub GetWebLogic { $url = "http://" . $server . ":" . $port . "/HttpController?Get +Page= +UserLogonForm"; if ($Testing eq "Yes" ) { print "Checking Dynamic Page\n"; } $ua = new LWP::UserAgent; $request = HTTP::Request->new(GET => $url); $response = $ua->request($request); if ($response->is_success) { $dynamic = $response->content; } @dynamic = split(/\n/,$dynamic); foreach $line (@dynamic) { ## Check the output of the web page for the HTML <HEAD> tag if ($line =~ /<HEAD>/i) { if ($Testing eq "Yes") { print "Found the Dynamic HTML +<HEAD +> tag\n"; } $DynamicPageCheckOK = "Yes"; } } # HERE if ($DynamicPageCheckOK eq "Yes") { ## Page returned do noting } else { ## Page didn't return generate an error &GenerateServerError; } # } # MOVE THIS }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Waiting for a response
by tachyon (Chancellor) on Apr 10, 2002 at 20:12 UTC | |
by wardk (Deacon) on Apr 10, 2002 at 20:40 UTC |