Perl Script Not Reading Input Files Correctly

This is one of the strangest things that's happening to me.
I'm writing a new Perl script that is trying to read a file.
The file is originally in .mof format, but I also saved the contents into a .txt file.

As a simple test, I wrote this:

#!/user/bin/perl -w
use strict;

#open(NODEFILE, "<nodes.mof");
open(NODEFILE, "<test.txt");
my $count = 0;
while (<NODEFILE>) {
    my $line = $_;
    #chomp($line);
    print "$line";
    if ($count == 3) {
        last;
    }
    $count++;
}
close(NODEFILE);

Whether I open the .mof file or .txt file, I always get this output:
p r a g m a n a m e s p a c e ( " \ \ \ \ . \ \ R o o t \ \ O p e n v i e w \ \ d a t a " )

i n s t a n c e o f O V _ N o d e G r o u p
{

The result should appear like this:
#pragma namespace("\\\\.\\Root\\Openview\\data")

instance of OV_NodeGroup

So why the heck would the script be putting those spaces when reading the file??

Was this input file edited in notepad by any chance? It looks like it's been saved as 16-bit Unicode -- the weird char at the beginning is a special marker telling Windows it's a unicode .txt file, and the characters are all 16-bit, with the high byte blank because you're using glyphs <256.

Ahh, I see.
In that case, any other format for the characters would work properly?

That's what the contents of the file really are, so it is reading it fine. You just got Unicode when you expected ASCII. Or got something stranger when you expected ASCII -- what is MOF? If this was never readable text to begin with, just renaming it won't make it suddenly be readable text.