in reply to Re: if/while/else problem
in thread if/while/else problem

This would have been caught had you included use strict;use warnings.

With not one but three warnings, even!

Unquoted string "file" may clash with future reserved word Name "main::file" used only once: possible typo -s on unopened filehandle file