in your
while loop,
$_ is only the current line of the file in
QUESTIONS - the globbing operator doesn't know that you are using a different delimiter than just a \n.
Insta-update: sorry to insult your intelligence - reviewing the following nodes I finally understood what the input record separator does... which was nice for me but not much help to you. So I now realise that my solution may be a good solution, but it's not a solution to the real problem. But here, for the benefit of a laughing posterity, it is:
Unless memory is a constraint or
questions is a really huge file, I think the simplest solution would be to read the whole file into a scalar, and then split it into an array of questions with
@questions = split (/===\n/, $scalar).
Then you can run your loop, but instead of
while (<QUESTIONS>) {
you would use
for (@questions) {
§
George Sherston
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.