assuming that the lastest code is a copying error and $name should read $maxsize, then the problem is not in the if statement, it is later in the code when you use %files to do something.
modifying your print to include $files{$maxsize} would verify this.
If the $name is in your existing code, then that explains your problem. Because $maxsize is the variable with the data.