CARVIEW |
Select Language
HTTP/2 200
cache-control: max-age=43200
server: Combust/Plack (Perl)
vary: Accept-Encoding
content-encoding: gzip
content-length: 2745
content-type: text/html; charset=utf-8
last-modified: Sat, 11 Oct 2025 15:45:31 GMT
traceparent: f4aa8c57d87a5429b2ed38df6d71fca9
strict-transport-security: max-age=15768000
Diamond iteration (was: Fighting the Good Fight against spam deluge) - nntp.perl.org
Front page | perl.perl5.porters |
Postings from August 2008
nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About

Diamond iteration (was: Fighting the Good Fight against spam deluge)
From:
Tom ChristiansenDate:
August 1, 2008 08:27Subject:
Diamond iteration (was: Fighting the Good Fight against spam deluge)Message ID:
32336.1217604417@chthonIn-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
- Re: Diamond iteration (was: Fighting the Good Fight against spam deluge) by Tom Christiansen
- Re: Diamond iteration (was: Fighting the Good Fight against spamdeluge) by H.Merijn Brand
- Re: Iterator::Diamond (Was: Re: Fighting the Good Fight against spam deluge) by Tom Christiansen
- Re: Fighting the Good Fight against spam deluge by Johan Vromans
- Re: Fighting the Good Fight against spam deluge by chromatic
- Fighting the Good Fight against spam deluge (was: Senatorial (Senescent?) reflective pause) by Tom Christiansen
- Re: Fighting the Good Fight against spam deluge (was: Senatorial(Senescent?) reflective pause) by Tim Bunce
- Re: Fighting the Good Fight against spam deluge (was: Senatorial (Senescent?) reflective pause) by jm
- Re: Fighting the Good Fight against spam deluge (was: Senatorial (Senescent?) reflective pause) by jvromans
- Diamond iteration (was: Fighting the Good Fight against spam deluge) by Tom Christiansen
- Re: Fighting the Good Fight against spam deluge by Roland Giersig
- Re: Fighting the Good Fight against spam deluge by Johan Vromans
- Re: Fighting the Good Fight against spam deluge by chromatic
- Re: Fighting the Good Fight against spam deluge by H.Merijn Brand
- Re: Fighting the Good Fight against spam deluge by Roland Giersig
- Re: Fighting the Good Fight against spam deluge by jvromans
- Re: Fighting the Good Fight against spam deluge by Tom Christiansen
- Re: Fighting the Good Fight against spam deluge by Johan Vromans
- Re: Fighting the Good Fight against spam deluge by Roland Giersig
- Re: Fighting the Good Fight against spam deluge by H.Merijn Brand
nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About