The following prints out all lines - also the ones, that doesnt match
the regular expression.
#!/usr/bin/perl -w
open FILEHANDLE, "soatest.soa";
while (<FILEHANDLE>){
if (/^\*| XI/) {
print "match in line: $.\n";
}
}
DOH! I found out that the above works as intended. I just "forgot" to
escape the | in the regexp.
I don't believe you. Show us an example of soatest.soa that demonstrates
this behavior.
>
> #!/usr/bin/perl -w
> open FILEHANDLE, "soatest.soa";
> while (<FILEHANDLE>){
> if (/^\*| XI/) {
> print "match in line: $.\n";
> }
> }
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
He said in his other reply that he forgot to escape the pipe in the
regex (so it wasn't meant to be an alternation.)
>> #!/usr/bin/perl -w
>> open FILEHANDLE, "soatest.soa";
>> while (<FILEHANDLE>){
>> if (/^\*| XI/) {
>> print "match in line: $.\n";
>> }
>> }
So it should be:
while (<FILEHANDLE>){
if (/^\*\| XI/) {
--
szr