In-Reply-To: Message from jvromans@squirrel.nl (Johan Vromans) of "Fri, 01 Aug 2008 12:28:49 +0200." <18578.58721.180685.719191@phoenix.squirrel.nl> > [Quoting Tom Christiansen, on July 31 2008, 16:15, in "Fighting the Good Fi"] >> In-Reply-To: Message from Johan Vromans <jvromans@squirrel.nl> >>> I'd go for a nice iterator class instead of <<<<>>>> weirdness. >> But now I'm curious--a condition for which, per Dorothy Parker, there >> is no cure :). Still, I'll try to cure it by asking whether you >> might you mean: >> (1) A class that has some sort of: >> >> use overload "<>" => sub { ... }; > Basically, yes. Good! > =head1 NAME > Iterator::Diamond - Iterate through the files from ARGV > =head1 VERSION (and so and so forth) Gosh, Johan, you're ahead of the game! With the doc/spec all complete and written out nicely like that, that makes it what, like 90% done? (and only 90% to go, I know, I know. :-) Does it iterate per glob, too? ;-} I really need to break myself from using open(SETUP, <~joeblow/.exrc>) at least, or maybe even also # DON'T NEED: chdir <~joeblow> || grump(); while ($dot_his = <~joeblow/.??*>) { # CUZ gets full pathname next unless -f -r -T $dot_his; # no, no -A :-) open(SETUP, "< $dot_his\0") || grump(); ... } but it's just so danged convenient. The problem was that last I looked, you have to finish the iteration yourself (as in example #2 with the while), or else there'll be a dangling dirhandle left unclosed and consuming system resources: one of your process's FDs--and also thus one out of the syswide UFD table in the kernel, too. I know: old perl hackers, like old nuns, have strange old habits. I do think (but don't quote me; quote him if you can) that Larry likes the angle-operator (as he calls it) to be an iterator, or rather *the* iterator, and that classes that co-opt it for their own iteration strategies are cool. That makes your idea cool. I still yearn for <> to work on DHs opened by opendir, too. Never saw why it didn't. $his_dir = <~joeblow>; # XXX: just lost an FD opendir(DH, $his_dir) || grump(); ### chdir($his_dir) || grump(); ### "I hate programs that chdir" --Boyd Roberts while (<DH>) { next unless /^\./; next unless -f -r -T; # WRONG: now needs $his_dir! open(SETUP, "< $his_dir/$_\0") || grump(); .... } --tom