Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!bu.edu!nntp-read!composer From: composer@chem.bu.edu (Jeff Kellem) Newsgroups: comp.lang.perl Subject: Re: Crafty automatic file deletion? Message-ID: Date: 29 Mar 91 04:19:15 GMT References: <126507@uunet.UU.NET> <126658@uunet.UU.NET> Sender: news@bu.edu.bu.edu Reply-To: composer@chem.bu.edu Organization: Boston University Chemistry Department Lines: 57 In-reply-to: rbj@uunet.UU.NET's message of 28 Mar 91 21:03:39 GMT In article <126658@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes: > 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. I just glanced over find2perl again; doesn't look too complex. :) It's just implementing what find does. The most "complex" part about find2perl may just be that it generates a perl script.. (?) Of course, maybe you're considering the cpio/tar writing that's done inside the perl script? But, also generating the perl script doesn't seem that complex to me either..maybe it's just my twisted mind. ;-) It looks like Larry has find2perl attempt to produce readable code, too. Wasn't that nice... :) > 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. Yep, it was posted to c.l.p a couple times. But, there was (of course) little documentation. There's always the source, right? ;-) > 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)' That shouldn't be too hard to add. Let's see.. maybe add something similar to this (definitely untested) with the list of 'elsif's near "elsif ($_ eq 'name') {" ? elsif ($_ eq 'load') { die "-load must have a filename argument\n" unless @ARGV; $initload .= 'require "' . shift . qq{";\n}; next; } and add the following line before the first "if ($initls) {" line: print $initload, "\n" if $initload; That should do it, I hope. No checks are made that the filename in '-load filename' (maybe that should be -require?) really exists. If ya want to add it, go ahead. :-) > I'm not clear on whether the current filename is in > $file, $name, or $_. It looks like the current filename is in $name. There may be a place where Larry left a $_ and meant $name in the code; but it also probably doesn't make a difference in that case. I'll have to look at it a little more closely to make sure; I've only had time to glance at it. Cheers... -jeff Jeff Kellem Internet: composer@chem.bu.edu