I am trying to find the size of a file using the -s
operator. It looks like this:
my $filesz = -s $filename
I tried lots of various way, but it can not get this size.
However, if I give static content instead of filename, it works fine
For example:
$filesz = -s "/tmp/abc.txt"
This works fine.
I tried adding "
in the filename, it didn't work. I removed \n
from filename using chomp
, but the problem remains the same. What's wrong here?
-s $filename
works just fine; the only conclusion is that there's no file with the name contained in $filename
. Take a very close look at the contents of $filename
, and make sure that your working directory is what you think it is.