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 (<FILEHANDLE>){
> if (/^\*| XI/) {
> print "match in line: $.\n";
> }
> }
>
> This conditional seems to be true for all lines (although they don't
> match /^\*| XI/). What is the correct syntax?
>
> Best regards,
> Kenneth
>
>
It helps if you can provide sample data that you can replicate the issue with.
It seems to work for me.
__CODE__
#! /usr/bin/perl
# Always...
use warnings;
use strict;
#!/usr/bin/perl -w
while (<DATA>){
if ( /^\*| XI/ ) {
print "match in line: $.\n";
}
}
__DATA__
1
2
* LINE
4
5 XI
6
__OUTPUT__
match in line: 3
match in line: 5
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/