Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

First of all, thank you for all of the replies.

To clarify: the input files are just text files created (and edited) by the user. It is possible for a file to be created (or edited) on one platform and then moved to another to be processed, but I expect this to be a rare occurrence. That said, it already happened. :)

After reading the replies here and thinking about this a little more, I think preprocessing is the best way to go in this case. My initial reluctance towards this approach stems only from the fact that each input file will be reprocessed every time the program is run. Thinking out loud: I would be very surprised if any one input file exceeded 1 MB, so slurping it is not an issue with respect to memory. Maybe I could save time by only writing the file back out if a newline character did not match \n (figuring out how to do that will be the next step - perhaps using binmode to make sure they don't get converted to \n on input (per monkey_boy's suggestion), or something like msemtd's example). I will also look into adamk's File::LocalizeNewlines module.

periapt and Drgan summed up the implementation and advantage of this approach quite nicely. I'll write a sub to preprocess the files and see how it goes.

Thanks again for the comments. I appreciate the input.

bobf


In reply to Re: Newlines: reading files that were created on other platforms by bobf
in thread Newlines: reading files that were created on other platforms by bobf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-19 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found