in reply to Re: When modules install in perl5
in thread When modules install in perl5
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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: When modules install in perl5
by haukex (Archbishop) on Sep 27, 2017 at 12:30 UTC | |
|
Re^3: When modules install in perl5
by Anonymous Monk on Sep 26, 2017 at 18:35 UTC |