Results 1 to 1 of 1
I am ashamed of myself that I cannot figure this out on my own.
I am trying to write a small Perl script that will display the amount of data ...
- 09-11-2009 #1
Perl: Parsing Data in Trash Can

I am ashamed of myself that I cannot figure this out on my own.
I am trying to write a small Perl script that will display the amount of data in the trash can (KDE). I plan on using this as part of my Conky script.
The output I get is the same as if I had run the 'du -k' command at the shell except this also places a closing parenthesis at the end.Code:#! /usr/bin/perl use warnings; use strict; my @du=`du -m ~/.local/share/Trash/files/`; print "total(@du)\n"; sub total { my @du2=shift; my $size=0; foreach (@du2) { if ($du2[$_] =~ /^(\d+)/) { $size += $1; } } $size; }
That and I just realized that that "." entry tells me that it is 739MB when I know there is 202MB in the trash can.
What am I doing wrong?
P.S. I'm sure there's an easier way to do this but now I'm just so determined to get this to work first before I try an easier way. I've already tried opening a directory handle to the trash directory and then using the stat() function to get the size but that didn't work.


Reply With Quote