use File::stat qw(stat); sub file_mode { my ($path) = @_; -f $path or return -1; my $stat = stat($path) or return -1; return $stat->mode; }