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 only pring those few lines.

On Wed, Aug 6, 2008 at 11:18 AM, Kenneth Brun Nielsen <
[EMAIL PROTECTED]> 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";
> while (<FILEHANDLE>){
>    if (/^\*| XI/) {
>        print "match in line: $.\n";
>    }
> }
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

Reply via email to