Hello all,
I write CGI scripts for my website in PERL. When I used to upload them with my
FTP program I made sure to do so in ASCII mode rather than binary. My host
made me switch to sFTP however. I use FIlezilla, and can't for the life of me
find out how to choose the mode on that. Unfortunately, binary is the default
mode. I don't like programming when the file displays ASCII endline
characters. I'd rather see clear, distinct lines rather than one long line
broken up with those vertical rectangles. When I download a script from my
site for editing it looks terrible. So I wrote a little program to fix that:
open (NEW, '>niceviewscript.pl') or die "Couldn't open file for writing";
open (FILE, 'script.pl') or die "Couldn't open file for reading";
while (<FILE>) {
$line = $_;
chomp($line);
print NEW "$line\n";
}
close (FILE);
close (NEW);
It works great. How do I get it to go in reverse though so it will work when I
upload it? I figured out that the ASCII number for those vertical rectangles
that represent line breaks was 10. So I tried:
$sillyrectangle = chr(10);
open (NEW, '>workingscript.pl') or die "Couldn't open file for writing";
open (FILE, 'niceviewscript.pl') or die "Couldn't open file";
while (<FILE>) {
$line = $_;
chomp($line);
$withnewend = $line . $sillyrectangle;
print NEW $withnewend;
}
close (FILE);
close (NEW);
Why doesn't this work? The newly created file looks just like the old one.
Now, if anyone can tell me how to upload in ASCII mode (assuming that's even
possible) that will solve my problem even better of course. But now I'm
curious as to why my program for switching back doesn't work.
Thank you!
Fred