Since this is a different topic than the one in the root node, if you have more issues/questions, I recommend starting a new thread. There are a few issues with the code, and potential improvements:

Personally I find the regex s/[\n\r][\n\r]/\n/g a little too flexible: If the file for some reason contains mixed CR/LF line endings, this regex might muck them up even more. Plus, if there are mixed endings, just checking the first line isn't enough. Here's how I might have written a script like this, even though there is no need to reinvent this wheel - for example, the fromdos tool from the Tofrodos package could already be installed on your system.

#!/usr/bin/env perl use warnings; use strict; use Getopt::Std 'getopts'; our $VERSION = '0.01'; $Getopt::Std::STANDARD_HELP_VERSION = 1; getopts('qi', \my %opts) or die "Usage: $0 [-q] [-i] FILE(s)\n"; if ( !@ARGV || (!$opts{i} && $opts{q}) ) { warn "No actions to perform\n"; exit 1 } for my $file (@ARGV) { open my $ifh, '<:raw', $file or die "$file: $!"; my $data = do { local $/; <$ifh> }; close $ifh; if (not $opts{q}) { my $cr = () = $data=~/\x0D(?!\x0A)/g; my $lf = () = $data=~/(?<!\x0D)\x0A/g; my $crlf = () = $data=~/\x0D\x0A/g; print "$file: ", ( join(', ', $cr?"$cr CR":(), $lf?"$lf LF":() +, $crlf?"$crlf CRLF":() ) || 'no CR or LF' ), "\n"; } if ($opts{i}) { $data =~ s/\x0D\x0A?|\x0A/\n/g; open my $ofh, '>:raw', $file or die "$file: $!"; print $ofh $data; close $ofh; } }

In reply to Re^3: When modules install in perl5 by haukex
in thread When modules install in perl5 by cristofayre

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.