Yes, a file with a gz extension is still a file*.
Here is an example that shows two ways to get the size of a file: using the file test -s (see -X in perlfunc) and the function stat. Note that both of these may not be 100% portable, as per the docs.
use strict; use warnings; my $file = 'find_my_size.tar.gz'; my $size = -s $file; print "size of $file by -s is $size\n"; my @filedata = stat $file; print "size of $file by stat is $filedata[7]\n";
*Unless it's a directory that ends in .gz, etc
In reply to Re: how to get filesize
by bobf
in thread how to get filesize
by llobrin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |