Re: Newbie - Simple conditional on regexp match

2008-08-08 Thread Kenneth Brun Nielsen
On 6 Aug., 14:05, [EMAIL PROTECTED] (Rob Coops) wrote: > You are almost right, since it prints all lines all lines match. > > Could you explain what it is that you are trying to match, that way people > might be able to help getting the regex right. i forgot about this thread, since it took so lon

Re: Newbie: Simple conditional on regexp match

2008-08-08 Thread Kenneth Brun Nielsen
On 6 Aug., 16:45, [EMAIL PROTECTED] (Yitzle) wrote: > On Wed, Aug 6, 2008 at 4:29 AM, Kenneth Brun Nielsen > <[EMAIL PROTECTED]> wrote: > > Within a perl program, I want to go to a particular mode when a > > keyword is found. The keyword is a regexp. > > > E.g. > > #!/usr/bin/perl -w > > open FILE

Re: Newbie: Simple conditional on regexp match

2008-08-06 Thread yitzle
On Wed, Aug 6, 2008 at 4:29 AM, Kenneth Brun Nielsen <[EMAIL PROTECTED]> wrote: > Within a perl program, I want to go to a particular mode when a > keyword is found. The keyword is a regexp. > > E.g. > #!/usr/bin/perl -w > open FILEHANDLE, "soatest.soa"; > while (){ >if (/^\*| XI/) { >p

Re: Newbie - Simple conditional on regexp match

2008-08-06 Thread Rob Dixon
Kenneth Brun Nielsen wrote: > > I need to make a conditional on a regular expression match. How can I > do that? > > E.g. in the code below, it prints all lines, and NOT only the ones > that match. How can I make the boolean test correct? > > #!/usr/bin/perl -w > open FILEHANDLE, "soatest.soa"; >

Re: Newbie - Simple conditional on regexp match

2008-08-06 Thread Rob Coops
You are almost right, since it prints all lines all lines match. Could you explain what it is that you are trying to match, that way people might be able to help getting the regex right. The way you are looking at the file line by line is valid and if your regex matches only a few lines it will o

Newbie - Simple conditional on regexp match

2008-08-06 Thread Kenneth Brun Nielsen
I need to make a conditional on a regular expression match. How can I do that? E.g. in the code below, it prints all lines, and NOT only the ones that match. How can I make the boolean test correct? #!/usr/bin/perl -w open FILEHANDLE, "soatest.soa"; while (){ if (/^\*| XI/) { print "m

Newbie: Simple conditional on regexp match

2008-08-06 Thread Kenneth Brun Nielsen
Within a perl program, I want to go to a particular mode when a keyword is found. The keyword is a regexp. E.g. #!/usr/bin/perl -w open FILEHANDLE, "soatest.soa"; while (){ if (/^\*| XI/) { print "match in line: $.\n"; } } This conditional seems to be true for all lines (although