sugarkane

msg:444813 | 7:32 pm on Jan 28, 2004 (gmt 0) |
Change your regex to: /(error.*?){2,}/gi and it should work. Another way is a bit more of a kludge, but may be useful in a wider context (eg you don't know how many times 'Error Pages' appears in the document, but wanted to ignore them all) would be to do a regex substitution on 'Error Pages' before and after the test so that it no longer matches, eg: $content=~s/Error Pages/Er1234567ror Pages/g; # Do your test here $content=~s/Er1234567ror Pages/Error Pages/g;
|
lindajames

msg:444814 | 9:09 pm on Jan 30, 2004 (gmt 0) |
sugarkane mentioned that i can use the following: $content=~s/Error Pages/Er1234567ror Pages/g; if ($response->is_success && $Content!~ /error/i) { $content=~s/Er1234567ror Pages/Error Pages/g; # carry on with whatever you're doing if 'error' is found } else { $content=~s/Er1234567ror Pages/Error Pages/g; # carry on with whatever you're doing if 'error' is NOT found } but the problem is i cannot get it to work with my code. my code looks as follows, can anyone please help me get the above code to work with the code below where it reads if ($response->is_success && : my $request = GET $query_string; $request->authorization_basic($User_name, $Password); my $response = $ua->request($request); $Content = $response->content; if ($response->is_success && $Content!~ /error (?!pages)/i) { return $response->content; } else { $Error_msg = $response->message; return undef; } }
|
sugarkane

msg:444815 | 12:28 am on Feb 1, 2004 (gmt 0) |
my $request = GET $query_string; $request->authorization_basic($User_name, $Password); my $response = $ua->request($request); $Content = $response->content; $content=~s/Error Pages/Er1234567ror Pages/g; if ($response->is_success && $Content!~ /error/i) { $content=~s/Er1234567ror Pages/Error Pages/g; return $response->content; } else { $Error_msg = $response->message; return undef; } } As I mentioned earlier it's a bit of a kludge, but should hopefully sort out the problem in your particular case.
|
lindajames

msg:444816 | 12:52 am on Feb 1, 2004 (gmt 0) |
thanx, i'll try it out
|
dkubb

msg:444817 | 4:07 am on Feb 1, 2004 (gmt 0) |
The following should work without any kludges. It uses a negative look-ahead assertion to look for the exact word "error" that is not followed by the word "pages". Also note that some of the other examples in this thread would mistakenly match words that have error as a substring, like "terror" or "errors". You can account for this by using \b to match the word boundaries. if($response->is_success and $response->content !~ /\berror\b(?!\s+pages)/i) { return $response->content; } else { $Error_msg = $response->message; return undef; }
|
lindajames

msg:444818 | 8:52 pm on Feb 1, 2004 (gmt 0) |
thanx dkubb, it worked. can you explain what exactly the line below does: if($response->is_success and $response->content!~ /\berror\b(?!\s+pages)/i) { cheers
|
|