File size with FIELDS
#!/usr/bin/perl
use warnings;
use strict;
use File::stat qw(:FIELDS);
my $filename = "data.txt";
if (stat $filename) {
print "'$filename' is ", $st_size,
" bytes and occupies ", $st_blksize * $st_blocks,
" bytes of disc space \n";
} else {
print "Cannot stat $filename: $| \n";
}
Related examples in the same category