Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!rbj From: rbj@uunet.UU.NET (Root Boy Jim) Newsgroups: comp.lang.perl Subject: Re: Crafty automatic file deletion? Message-ID: <126658@uunet.UU.NET> Date: 28 Mar 91 21:03:39 GMT References: <126507@uunet.UU.NET> Organization: UUNET Communications Services, Falls Church, VA Lines: 44 In article jik@athena.mit.edu (Jonathan I. Kamens) writes: >In article <126507@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes: > Otherwise, First pick all the files matching this pattern, then process them. > > find ~ -name "*.rm.*.*" -print | maybe-remove > > Of course now you have to write the latter program. > A good language to write it in would be perl. > >If maybe-remove is written in perl, then it is ridiculous to do the >find in a separate process, since the perl can do it in the same >process as the maybe-remove stuff. I almost said that. However, while it is "possible" to move the find into the script, it is nontrivial to do. Look at the complexity of find2perl to see what I mean. Besides, you have to be smart enuf not to follow symbolic links :-) "Rediculous" is too strong a word. In fact, but for the existence of find2perl, "rediculous not to" is closer to the truth. >Doesn't the perl distribution come with "find2perl" or something like >that? Well, it seems to, but I see no documentation. It may have been posted to this group, but right now I'm too lazy to look for it. However, given the existence of find2perl, one should probably use it. After a careful scan, it seems that it can be used more or less as a replacement for find, plus a few extra niftys, such as eval. There is one thing missing, however; eval looks pretty neat, but can become complicated in a hurry. I would like the ability to load code into the script in order to simplify things. Thus: find2perl ~ -load maybe_remove.pl -name "*.rm.*.*" \ -eval '&maybe_remove($file)' I'm not clear on whether the current filename is in $file, $name, or $_. -- [rbj@uunet 1] stty sane unknown mode: sane