Hi
I have a rather complicated pattern matching code which I am not able to figure out.
open (LU, "> lookup.txt"
open (NONLU, "> lookup.rej"
open (WISLU, "wisdom.qsl"
while (<WISLU>)
{
if (/n01/)
{
if (/n01\s*((?:\(*\w*\)*\s*\(*-*&*'*\/*\.*:*,*"*#*%*\+*£*\s*\)*)*);c=(\w+)\(?(\d*,?\d*)\)?\.(?:eq|in)\.\(?(-?\d+:?\d*)\)?/)
{
print LU "$2~$3~$4~$1\n";
} else
{
print NONLU "zz $_\n";
}
}
}
The wisdom.qsl file looks something like this:
n01 Pipex;c=A140D(1).eq.1
n01 LineOne;c=A140D(2).eq.1
n01 America On Line (AOL);c=A140D(3).eq.1
n23Prompted awareness of Internet Service Providers;norow;unl1
n03
n01 1;c=A150.eq.1
n01 2;c=A150.eq.2
n01 3;c=A150.eq.3
n01 4;c=A150.eq.4
n01 5;c=A150.eq.5
n01 6;c=A150.eq.6
n01 7-8;c=A150.eq.7
n01 9-10;c=A150.eq.8
n01 Yahoo!;c=ilik11(35).eq.1
n01 11 to 15 minutes;c=INET10(1,4).in.(11:15)
The output expected in lookup.txt is like this :
A140D~1~1~Pipex
A140D~2~1~LineOne
A140D~3~1~America On Line (AOL)
A150~~1~1
A150~~2~2
A150~~3~3
A150~~4~4
A150~~5~5
A150~~6~6
A150~~7~7-8
A150~~8~9-10
INET10~1,4~11:15~11 to 15 minutes
Can someone explain to me what the pattern matching expression means ?
-Anukta
I have a rather complicated pattern matching code which I am not able to figure out.
open (LU, "> lookup.txt"
open (NONLU, "> lookup.rej"
open (WISLU, "wisdom.qsl"
while (<WISLU>)
{
if (/n01/)
{
if (/n01\s*((?:\(*\w*\)*\s*\(*-*&*'*\/*\.*:*,*"*#*%*\+*£*\s*\)*)*);c=(\w+)\(?(\d*,?\d*)\)?\.(?:eq|in)\.\(?(-?\d+:?\d*)\)?/)
{
print LU "$2~$3~$4~$1\n";
} else
{
print NONLU "zz $_\n";
}
}
}
The wisdom.qsl file looks something like this:
n01 Pipex;c=A140D(1).eq.1
n01 LineOne;c=A140D(2).eq.1
n01 America On Line (AOL);c=A140D(3).eq.1
n23Prompted awareness of Internet Service Providers;norow;unl1
n03
n01 1;c=A150.eq.1
n01 2;c=A150.eq.2
n01 3;c=A150.eq.3
n01 4;c=A150.eq.4
n01 5;c=A150.eq.5
n01 6;c=A150.eq.6
n01 7-8;c=A150.eq.7
n01 9-10;c=A150.eq.8
n01 Yahoo!;c=ilik11(35).eq.1
n01 11 to 15 minutes;c=INET10(1,4).in.(11:15)
The output expected in lookup.txt is like this :
A140D~1~1~Pipex
A140D~2~1~LineOne
A140D~3~1~America On Line (AOL)
A150~~1~1
A150~~2~2
A150~~3~3
A150~~4~4
A150~~5~5
A150~~6~6
A150~~7~7-8
A150~~8~9-10
INET10~1,4~11:15~11 to 15 minutes
Can someone explain to me what the pattern matching expression means ?
-Anukta