Sunday, July 17, 2011

To find the filesize in perl

Solution 1:
For example for file test.txt.It is done by using the stat function in File module

use File::stat;
my $filesize = stat("test.txt")->size;
print "Size: $filesize\n";

Output:

Size: 42

Solution 2 :
It is done using the -s option

my $dd= -s "test.txt";
print "Size : $dd";

Output:

Size: 42

No comments:

Post a Comment