Groups > Novell > Perl for NetWare > Re: How to search a file?




How to search a file?

How to search a file?
Wed, 06 Dec 2006 16:13:21 GMT
Hi,

I would like to search a text file for a line that has three colon's (:) 
and the word error.

However I am pretty perl illiterate.

I know the following line works for one colon and the word error, can 
anyone help me modify it so it works with 3 colon's?

if ($log_to_parse =~ m/\:.*\ error/i)


Post Reply
Re: How to search a file?
Wed, 06 Dec 2006 17:39:11 GMT
Hi Brian,

Brian Mantler <brianmantler@nowhere.com> wrote in 
news:Xns98917228C35A4brianmantlernowherec@130.57.1.81:

> I would like to search a text file for a line that has three colon's (:) 
> and the word error.
> 
> However I am pretty perl illiterate.
> 
> I know the following line works for one colon and the word error, can 
> anyone help me modify it so it works with 3 colon's?
> 
> if ($log_to_parse =~ m/\:.*\ error/i)
yeah, regex is a real pain if you're no die-hard regex guy;
I'm not such one; but try this:
if ($log_to_parse =~ m/\:\:\:.*\ error/i)

Guen.
Post Reply
Re: How to search a file?
Fri, 08 Dec 2006 12:08:32 GMT
That seems to work for three colon's in a row, but not three colons 
anywhere on a line.

I did try several stabs at it but couldn't find the correct combination.


Guenter <devforums@novell.com> wrote in
news:3fDdh.10207$jS4.1864@prv-forum2.provo.novell.com: 

> Hi Brian,
> 
> Brian Mantler <brianmantler@nowhere.com> wrote in 
> news:Xns98917228C35A4brianmantlernowherec@130.57.1.81:
> 
>> I would like to search a text file for a line that has three colon's
>> (:) and the word error.
>> 
>> However I am pretty perl illiterate.
>> 
>> I know the following line works for one colon and the word error, can
>> anyone help me modify it so it works with 3 colon's?
>> 
>> if ($log_to_parse =~ m/\:.*\ error/i)
> yeah, regex is a real pain if you're no die-hard regex guy;
> I'm not such one; but try this:
> if ($log_to_parse =~ m/\:\:\:.*\ error/i)
> 
> Guen.
> 
Post Reply
Re: How to search a file?
Fri, 08 Dec 2006 15:50:42 GMT
Hi Brian,
Brian Mantler <brianmantler@nowhere.com> wrote in 
news:Xns989348A64F38Dbrianmantlernowherec@130.57.1.81:

> That seems to work for three colon's in a row, but not three colons 
> anywhere on a line.
yep.
> 
> I did try several stabs at it but couldn't find the correct combination.
then please post the exact string you want to examine + the exact results you 
want to get - otherwise anyone who wants to help you is lost....

greetz, Guenter.
Post Reply
about | contact