While you're at it, write a parallel version of du.pl... Modern hard drives do scatter gather, and reading lots (say 10 or so) of dirs' contents' block sizes at a time would be interesting...
It would be cool if a parent kept 20 children pre-forked, and only told 10 children at a time to do their work load. The children upon fork would wait for some IPC from the parent, then do their work, then communicate the answer back to the parent, and die. I don't know if pre-forking is necessary to keep 10 children active, but it's something to make the task harder, and make you learn more! If you wanna learn perl, aim at over-engineered spaghetti. Give yourself a task fit for a mentally insane perl monk, and then you can say you've been to hell and back. Then repeat... On Mon, 2003-12-29 at 15:51, John W. Krahn wrote: > Jesper Noehr wrote: > > > > On Mon, 29 Dec 2003 13:19:29 -0800, John W. Krahn <[EMAIL PROTECTED]> wrote: > > > > > > $ ls -l test.txt > > > -rw-r--r-- 1 john users 187 Jul 9 11:54 test.txt > > > $ perl -le'print +(lstat shift)[11]' test.txt > > > 4096 > > > $ du -b test.txt > > > 4096 test.txt > > > $ du test.txt > > > 4 test.txt > > Great example, thanks. You have any idea how I can rehack my program to > > return what du does? That is, diskspaceusage. > > As you can see from the perl script above, the twelfth field of stat and > lstat is the block size. > > $ ls -l file.txt > -rw-r--r-- 1 john users 22982 Nov 13 23:28 file.txt > $ du -b file.txt > 24576 file.txt > $ perl -le'$x = shift; > $b = (lstat $x)[11]; > $s = -s _; > print "$s ", $s + ( $b - ( $s % $b ) ); > ' file.txt > 22982 24576 > > > > John > -- > use Perl; > program > fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>