in reply to Re: CPAN module unit test issues: OS line endings (how?)
in thread CPAN module unit test issues: OS line endings

The problem stemmed from the fact that Tie::File (which I use in this module) switches its record separator automatically when on either nix or Windows. So when my test data files were downloaded from CPAN on Windows, they still had Unix line endings and weren't being read in correctly.

In the end, before I open a file with Tie::File, I check to see what type of line endings it has, then I set Tie::File's recsep parameter to either \n or \r\n depending on the situation.

Note that I hardly ever use Windows, so didn't think to test it on that platform, and of course we haven't been getting Testers reports because of the issues.

I'm going to look at Tie::File tomorrow to check whether I'm missing something, or whether automatic record separation can be incorporated within it (just \n, \r\n).

Replies are listed 'Best First'.
Re^3: CPAN module unit test issues: OS line endings (Tie::File)
by tye (Sage) on Sep 18, 2015 at 03:34 UTC

    Why are you using Tie::File? I can't recommend that module as it is a fine example of getting a slight bit of superficial simplicity at the expense of way too much hidden complexity. Such things too often end up biting you before you are done (as happened here).

    I only skimmed a bit of the code. The only actual using of a tied array that I noticed was:

    @{$subs{$file}{TIE_file}} = @TIE_file;

    Which seems to provide absolutely zero benefit from the use of that module. That does nothing more than what a simple open and then @{...} = <$fh>; would do (except it is less efficient and leverages way more hidden complexity which leads to fragile surprises like not dealing well with line endings).

    That code also slurps the entire file contents into memory. This limits the size of problems that can be effectively handled by your module.

    - tye        

      (except it is less efficient and leverages way more hidden complexity which leads to fragile surprises
      ++ x 1000

      Cpanitis in a nutshell.

      I started off wanting to edit files in place by array element, and found Tie::File was nice and easy. As I expanded with the project, I guess I just went overboard and used it everywhere.

      Sometimes we just need someone more experienced to say "whoa, wait a minute, you're being ridiculous". :)