open FILE, '<', 'test.file' or die; while(){ s/\s+$//; print "line=[$_]\n"; } close FILE;