brian d foy wrote:
As I was playing around with dirhandles, I thought "What if..." (which
is actualy sorta fun to do in Pugs, where Perl 5 has everything
documented somewhere even if nobody has read it).

My goal is modest: explain fewer things in the Llama. If dirhandles
were like filehandles, there's a couple of pages of explanation I don't
need to go through.


I can iterate through the elements of a named array with [EMAIL PROTECTED]:

   my @a = < 1 2 3 4 5 >;
   for [EMAIL PROTECTED] { .say }   # but not =< 1 2 3 4 5 > :(

and I can read lines from a file:

   for =$fh { .say }

Should I be able to go through a directory handle that way too? A "yes"
answer would be very pleasing :)

   my $dh = "doc".opendir;
   for =$dh { .say }    # doesn't work in pugs

And, since we're using objects now, .closedir can really just be
.close, right?

Please.  I've always found the "opendir ... readdir ... closedir" set
to be clunky.

Also: why distinguish between "open" and "opendir"?  If the string is
the name of a file, 'open' means "open the file"; if it is the name of
a directory, 'open' means "open the directory".  If it's the name of a
pipe, it opens the pipe.  And so on.

Note that the above could be further shorthanded, as long as you don't
need the directory handle after the loop:

   for ="doc".open { .say }

Jonathan "Dataweaver" Lang

Reply via email to