You are trying to use the thing returned by stat as an object, but perldoc -f stat says it is merely a list containg the filesize on index seven. Try my $s = (stat($farm))[7]. Or, better yet, check the return value of stat first... Or try the -s operator (man perlfunc).