Path: cwi.nl!sun4nl!mcsun!uunet!cs.utexas.edu!convex!usenetFrom: tchrist@convex.COM (Tom Christiansen)Newsgroups: comp.lang.perlSubject: Re: The problems of Perl (Re: Question (silly?))Message-ID: <1992Jan17.053115.4220@convex.com>Date: 17 Jan 92 05:31:15 GMTReferences: <17458@ector.cs.purdue.edu> <1992Jan16.165347.25583@cherokee.uswest.com> <=#Hues+4@cs.psu.edu>Sender: usenet@convex.com (news access account)Reply-To: tchrist@convex.COM (Tom Christiansen)Organization: CONVEX Realtime Development, Colorado Springs, COLines: 83Nntp-Posting-Host: pixel.convex.comFrom the keyboard of flee@cs.psu.edu (Felix Lee)::And Perl is definitely awkward with data types. I haven't yet found a:pleasant way of shoving non-trivial data types into Perl's grammar.Yes, it's pretty aweful at that, alright. Sometimes I write perl programsthat need them, and sometimes it just takes a little creativity. Butsometimes it's not worth it. I actually wrote a C program the other day(gasp) because I didn't want to deal with a game matrix with six links per node.:Here's a very simple problem that's tricky to express in Perl: process:the output of "du" to produce output that's indented to reflect the:tree structure, and with each subtree sorted by size. Something like:: 434 /etc: | 344 .: | 50 install: | 35 uucp: | 3 nserve: | | 2 .: | | 1 auth.info: | 1 sm: | 1 sm.bakAt first I thought I could just keep one local list aroundat once, but this seems inherently recursive. Which meansI need an real recursive data structure. Maybe you coulddo it with one of the %assoc arrays Larry uses in the begatprograms, but I broke down and got dirty. I think the hardestpart was matching Felix's desired output exactly. It's notblazingly fast: I should probably inline the &childof routine,but it *was* faster to write than I could have written theequivalent C program.--tom--"GUIs normally make it simple to accomplish simple actions and impossibleto accomplish complex actions." --Doug Gwyn (22/Jun/91 in comp.unix.wizards)Tom Christiansen tchrist@convex.com convex!tchrist
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。