I don't know wether it's a typo or not but you are missing a
; on the first commented line.
You may also want to look at using $return to get data out of the productions rather than modifying global vars. Something like this may work
file: hdr body ftr
{
$return = {hdr => $item{hdr},
body => $item{body},
};
}
body: batch(s)
hdr: /^HDR.*\\n/
ftr: /^FTR.*\\n/
batch: bathdr tran(s) batftr
{
$return = {bathdr => $item{bathdr},
tran => $item{"tran(s)"},
};
}
bathdr: /^BHD.*\\n/
{
$return = substr($item[1], 30, 3);
}
batftr : /^BFT.*\\n/
tran: TR1 TR2
{
$return = {%{$item{TR1}},
%{$item{TR2}},
};
}
TR1: /^TR1.*\\n/
{
$return = { str4 => substr($item[1], 35, 8),
str2 => substr($item[1], 122, 5),
};
}
TR2: /^TR2.*\\n/
{
$return = {str3 => substr($item[1], 103,2)};
}
the return from the parser will be the datastructure you created and you can then print/manipulate it outside of the parser.
Not tested at all.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.