Check $! to see if any error occured. See perldoc perlvar.
Also, this isn't shell so you shouldn't be putting the variable name in quotes if you're only using it by itself. -s $filename is fine. If the variable you were trying to pass to -s were a filehandle glob reference, the quotes would actually break your code entirely by turning the reference into a useless string representation of its address.
my $size = -s $filename; die "Couldn't stat $filename: $!" if not defined $size;
Makeshifts last the longest.
In reply to Re: Getting file size
by Aristotle
in thread Getting file size
by Willman023
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |