You need to set the record separator to '>', like this: $/='>'. That way each call to <FILE> will get a single record rather than just part of the record. By default $/ is set to the new line and so if you leave your code as is, you are only getting up to the end of each line. See perlvar for more information.
A useful debugging tip is to print out each $line with begin and end markers: print STDERR "##$line##\n". The source of the problem would have been immediately clear had you done that. You might also enjoy this link from someone else who forgot to do that. By pure coincidence, Unbelievably Obvious Debugging Tip just happened to be in today's random pick of Selected Best Nodes
Best, beth
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|