Dear all,
I frequently write scripts that parse simple tab-delimited or comma-delimited files that have been created by other people. Typically they are created in Excel and they can be from windows or OS X platforms. I often run into the problem that a simple filehandle loop ( while(<FH>) ) will only read either the first or final line of the file. This is because the new line characters are not always \n as Perl likes- \r for OS X and \r\n for Windows. Preferably I would like to not have to bother working out what the problem is for each file and change the characters to \n using dos2unix or whatever, so I was wondering if anyone can suggest a good solution for this; is there a recommended module that has a method that performs this function?
-
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.
|