Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!convex!news From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: fun with scoping Message-ID: <1990Dec18.220515.19336@convex.com> Date: 18 Dec 90 22:05:15 GMT References: <111557@convex.convex.com> Sender: news@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 35 Nntp-Posting-Host: pixel.convex.com No one has said anything, except one person through mail. Here is the slightly touched up code that gets 'find -ls' output. #!/usr/bin/perl $fmt = 'a26 A9 A8 a*'; while (<>) { ($pre, $login, $group, $post) = unpack($fmt, $_); print pack($fmt, $pre, &id(*login), &id(*group), $post); } sub id { local(*id) = @_; $id{$id} = $id =~ /^\d+$/ ? $id : &id unless defined $id{$id}; $id{$id}; } sub login { (getpwnam($id))[2]; } sub group { (getgrnam($id))[2]; } Now answer me these questions three: 1. Why is this (or isn't this) a recursive program? 2. What are the associative arrays in this program, by name? 3. What are their favorite colors? People who already know the answers becasue they've corresponded with me please hold back until we get some fun tries. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "With a kernel dive, all things are possible, but it sure makes it hard to look at yourself in the mirror the next morning." -me