/Tools/scripts/dutree.doc

http://unladen-swallow.googlecode.com/ · Unknown · 54 lines · 45 code · 9 blank · 0 comment · 0 complexity · c740780e717bb6b96dd6878afb0a284f MD5 · raw file

  1. Path: cwi.nl!sun4nl!mcsun!uunet!cs.utexas.edu!convex!usenet
  2. From: tchrist@convex.COM (Tom Christiansen)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: The problems of Perl (Re: Question (silly?))
  5. Message-ID: <1992Jan17.053115.4220@convex.com>
  6. Date: 17 Jan 92 05:31:15 GMT
  7. References: <17458@ector.cs.purdue.edu> <1992Jan16.165347.25583@cherokee.uswest.com> <=#Hues+4@cs.psu.edu>
  8. Sender: usenet@convex.com (news access account)
  9. Reply-To: tchrist@convex.COM (Tom Christiansen)
  10. Organization: CONVEX Realtime Development, Colorado Springs, CO
  11. Lines: 83
  12. Nntp-Posting-Host: pixel.convex.com
  13. From the keyboard of flee@cs.psu.edu (Felix Lee):
  14. :And Perl is definitely awkward with data types. I haven't yet found a
  15. :pleasant way of shoving non-trivial data types into Perl's grammar.
  16. Yes, it's pretty aweful at that, alright. Sometimes I write perl programs
  17. that need them, and sometimes it just takes a little creativity. But
  18. sometimes it's not worth it. I actually wrote a C program the other day
  19. (gasp) because I didn't want to deal with a game matrix with six links per node.
  20. :Here's a very simple problem that's tricky to express in Perl: process
  21. :the output of "du" to produce output that's indented to reflect the
  22. :tree structure, and with each subtree sorted by size. Something like:
  23. : 434 /etc
  24. : | 344 .
  25. : | 50 install
  26. : | 35 uucp
  27. : | 3 nserve
  28. : | | 2 .
  29. : | | 1 auth.info
  30. : | 1 sm
  31. : | 1 sm.bak
  32. At first I thought I could just keep one local list around
  33. at once, but this seems inherently recursive. Which means
  34. I need an real recursive data structure. Maybe you could
  35. do it with one of the %assoc arrays Larry uses in the begat
  36. programs, but I broke down and got dirty. I think the hardest
  37. part was matching Felix's desired output exactly. It's not
  38. blazingly fast: I should probably inline the &childof routine,
  39. but it *was* faster to write than I could have written the
  40. equivalent C program.
  41. --tom
  42. --
  43. "GUIs normally make it simple to accomplish simple actions and impossible
  44. to accomplish complex actions." --Doug Gwyn (22/Jun/91 in comp.unix.wizards)
  45. Tom Christiansen tchrist@convex.com convex!tchrist