Bad Title I know,
I have a perl script that does, among other things, parse some flat text segments (an edi document) and formats it into readable
text with a description of the order that is then mailed out.
The problem i am having is that there is one particular line that can come in two ways in the same document;
PO1*001*780*EA*39.97*LE*IN
*004026605
*UP*631656
320015*VN*
FOR0007200
0CA
or
PO1*001*780*EA*39.97*LE*IN
*004026605
*UP*631656
320015*VN*
FOR0007200
0CA***IZ*7
2
The code that parses this line is currently;
<begin>
if (/PO1\*(\d+)\*(\d+)\*EA\*(
.*?)\*LE\*
IN\*(\d+)\
*UP\*(\d+)
\*VN\*(.*?
)$/o) {
if ((scalar $EDI_REF->{IEACLOSE}) == FALSE) {
$gnc_orders = join('',$gnc_orders,"\t", $6,"\n");
$nameprod = $6;
&{%dispatch->{CLEOLOG}}("O
RDER#: $EDI_REF->{ORDER} They ordered $6");
}
}
if (/PO1\*(\d+)\*(\d+)\*EA\*(
.*?)\*LE\*
IN\*(\d+)\
*UP\*(\d+)
\*VN\*(.*?
)\*\*\*IZ\
*(.*?)$/o)
{
if ((scalar $EDI_REF->{IEACLOSE}) == FALSE) {
$gnc_orders = join('',$gnc_orders,"\t", $6,"\n");
$nameprod = $6;
&{%dispatch->{CLEOLOG}}("O
RDER#: $EDI_REF->{ORDER} They ordered $6");
}
}
</end>
The problem is that the line can show up in both formats within the same document. I need this to be able to
parse the line, if it is a full line then pull the sixth variable and move on if it is not the full line then move on to the
second if statement but only pull one instance...
output of the log file shows that the script is grabbing both variables from the same line....this sucks :-((
2005-11-14 17:09:25 ORDER#: 850000002 They ordered SSGLU300000CA
2005-11-14 17:09:25 ORDER#: 850000002 They ordered SSGLU300000CA***IZ*300GM
Keep in mind, I am not a perl coder by any stretch, I inherited this script and although I can edit and fumble my way through basic
changes, outside of this, well, that's why i'm here :-))
Thanks for any help,
Start Free Trial