In-Reply-To: Message from jvromans@squirrel.nl (Johan Vromans)
of "Mon, 04 Aug 2008 13:38:44 +0200." <18582.59972.166202.659278@phoenix.squirrel.nl>
>[Quoting Roland Giersig, on August 4 2008, 12:23, in "Re: Fighting the Goo"]
>> I was thinking along the lines:
>>
>> package Iterator::Diamond;
>> @ISA = qw(Iterator::Files);
> Yes, that's what I'm thinking, too. BTW, would
> Iterator::FileList be a better name?
Hm, isn't *this* a filename iterator:
# run in perl source tree
while (<*.{[chy],sh,pl}>) {say}
But then what could we call this from yesterday?
while ( < {A,a,B,b,C,c,D}_{prints,return} > ) {
next unless defined &$_ ; # XXX
print "sub &$_ ";
if (/ret/) { print "returns ", &{\&$_} }
elsif (/pri/) { print "prints "; &{\&$_} }
else { die "XXX XXX"; }
} continue {
print "\n";
}
The first one iterates only on filenames that exist (and
it processes them only semi-alphabetically, stepping through
the {,,} lists sequentially).
The second, having no wildcards (including square brackets),
iterates across a list of strings, which have no relation to
filenames at all. I guess it's... a string iterator?
It's really convenient at times is all I know.
Hm...
*Surely* more folks--besides Jos Boumans and me--use that
lovely little perliciousness! :-)
>> # deal with ARGV, <> overloading, etc here
>That might be less trivial, but worth trying.
I wonder if people just want to be able to add
perl -MSome::Module -pe '....'
and get (or not get) the special processing. Front-end
A::B::Simple::XXX modules might, for various settings of XXX,
put @ARGV into 2- or 3-arg open mode, or even also some of
them prerun the map{}s for getting @ARGV tidied up to handle
.gz files or URL GETs.
Actually, that's long to type. Maybe not multiple modules,
but imports?
perl -MSome::Module=gzip,url -pe '....'
--tom