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!
It is only checking the single test file at this stage, which should print "File XYZ is incorrect" if its working#!/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";
In reply to Re^2: When modules install in perl5
by cristofayre
in thread When modules install in perl5
by cristofayre
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |