I was writing a script today in order to print out some data from a file. Maybe I'm retarded in picking perl to perform this job, but it was one of those times where I just picked a scripting language out of a hat and went with it. I hadn't scripted much in perl either so I figured I would give it a shot.
Anyway, the whole point of the script is to parse through a file line by line and perform a function based on that line. For debugging purposes, I simply printed the line with a carriage return(\n). When I started to run the script, it spat out a humungous, long line of text and then quit. Another additional piece of information is that the log file was created by another perl script I ran. This was run in windows, which by default uses the CR or carriage return. Given that I used the > operator at the command line instead using the OPEN function in perl to write to a log file on windows is the obvious reason this deviated from my expected result (unless I'm way off). The main reason I did that was pure laziness at the time. So, when I tried to parse through the file with perl on Linux, it spat out a huge line because all of the line breaks were CR and it was looking for LF to indicate the end of line.
I used sed to fix the line breaks (sed -e s/'\r'/'\n'/g disabled.txt).
The whole purpose of this script is to run a CLI tool with the line to delete users from our directory tree. The reasons behind this are incredibly convoluted so I won't go into them here, but the code I wrote can be seen below. I didn't know if it would hold any vested interest with the rest of the community considering that's probably documented somewhere, but I'm sure someone will run into it again. Just an interesting tidbit on how perl handle's those characters.
####### Written By vienessewaltzer ############
#Set the log file to use
my $file = "disabled.txt";
my $test = "test.txt";
open (F, "<$file") or die ("Could not open $file!");
open (T, ">$test") or die ("could not open $test!");
while (my $line = <F>)
print $line, "\n";
print T $line;
Also worth noting, when you write to a file with perl functions it adds CRLF together.