my $file_name = 'abc.txt'; # abc.txt is just one line simple txt file like "Hello world!". It's created by another program. The second the other program creates it, the code below tries to read it. # I know the following code is not the right thing to do. I would do it open (my $FILE, '<', $file_name) for reading. But it's legacy code and how the error is produced. So I just show it the way it is now. open(FILE, $file_name) or die "Can't open file $file_name $!\n"); my $line = ; print $line;