Apparently, you also have the line
use File::stat;
in your program, and forgot to mention it. File::stat overrides the built-in stat
function with a version that returns objects. You should read its documentation instead.
In your case, you'd want:
use File::stat;
my $mode = stat($filename)->mode;