in reply to My program hangs

Like Corion says you are reading from the wrong filehandle. But:
#!/usr/bin/perl;
You're on unix.
my $filename = 'C:\Perl\example.txt';
You're on windows. I'm confused, they can't be both right?

Replies are listed 'Best First'.
Re^2: My program hangs
by Corion (Patriarch) on Jun 23, 2014 at 13:18 UTC

    Windows does not care for the hashbang line of a script. Perl does care for the line, respectively, for the switches on that line.

    In that sense, they can both be right.