File size with FIELDS : File « File « Perl






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

1.Copy files
2.Copying a file using the File::Copy
3.Create a directory tree
4.Determine the contents of a directory tree?
5.File finder and callback
6.Find file
7.Find out if there's a copy of the dir program on this computer
8.File find closure
9.Using a Callback
10.Extracting file names from paths
11.$File::Find::prune = 1 if /dir1/;