i did use commands available on dos and also used unix head and grep
utils and made to get 5 files.
i used dir sort with size, made unix head -5 and then put that to
file,but i want to delete those and also compute size of d drive.
eg:
d:\test1.txt - 5kb
test2.txt 4kb
test3.txt 3kb
....
how can i write all in perl only?
thanks for any help
jay
I would use the File::Find module and its find() function to traverse
the directory tree on the d: drive and the file test operator -s to get
the file size. For each file found, I would save the file size and name
in an array of arrays (untested):
push( @files, [ -s $_, $File::Find::name] );
I would then sort this array by file size and print or delete the first
5 elements.
for my $file ( sort { $b->[0] <=> $a->[0] } @files ) {
# do whatever to first n elements
}
(You may have to swap $a and $b in the sort block function to sort by
increasing or decreasing size.)
You can get more details with these commands:
perldoc File::Find
perldoc -f -s
perldoc -f sort
Good luck.
--
Jim Gibson