For anyone who's curious, the REAL problem was that the file had been uploaded as DOS (CRLF) rather than UNIX (LF only) "Filezilla" auto corrects on upload - but not so cPanel "FileManager"

Now I got to write a script to check 200+ files on my Windows7 / Strawbery PERL local machine. I will use File::Find::Rule to reiterate through all the folders and sub domains, and open the first line of each file. If it's a CRLF, THEN I will open the file. make the change, and save it out again. Problem at present is getting grep to find the linefeed. Tried escaping and /\x0A\x0D/, but won't play ball!

#!/usr/bin/perl print "content-type: text/html\n\n"; use CGI::Carp qw( fatalsToBrowser ); use File::Find::Rule; $string="\x0D\x0A"; #my @files = File::Find::Rule->file()->name('*.pl')->in('/home/cristof +a/public_html/'); # set ->in('.') to start from current directory my @files=('D:/home/cristofa/public_html/cgi-bin/dummy/testme.pl'); for ($x=0; $x<@files; $x++){ open THEFILE, "<$files[$x]"; $first_line = <THEFILE>; print $first_line; close THEFILE; if (grep(/$string$/,$first_line)){ print File "$files[$x] is incorrect<br>"; # &correct_file; } } sub correct_file{ open (FILE, "<$files[$x]); while(<FILE>){ $tmp.=$_; } $tmp=~s/[\n\r][\n\r]/\n/g; open (FILE, ">$files[$x]); print FILE $tmp; close(FILE); $tmp=''; } print "All done";
It is only checking the single test file at this stage, which should print "File XYZ is incorrect" if its working

In reply to Re^2: When modules install in perl5 by cristofayre
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.