develooper Front page | perl.perl6.language | Postings from July 2005

Lazyness and IO

David Formosa
July 29, 2005 22:08
Lazyness and IO
Message ID:
I was thinking about lazyness and IO and worked out this potenial
gotcha.  In essence its quite simmler to the pipe buffering problems
you sometimes can get in perl5.

my IO $news = io("nntp://",:rw); # Open a nntp connection

my $banner  = =$news # Throw away the banner. So far so good.

say($news,"group perl.perl6.language"); # Also no problem
my $status = =$news;


my @artical <= grep { True .. /^.$/ } <= for =$news; # Is this
                                                      # construction 
                                                      # right?  Anyway
                                                      # you should get
                                                      # what I'm trying
                                                      # todo.

say($news,"article @artical[0]");

for =$news -> {say};
# What happens at this point? Lazyness means that only the first
# artical number has been read.  Does my for loop here have the side
# effect of causing the rest of artical list to be read into @artical?
# This is what I would hope would happen.

Please excuse my spelling as I suffer from agraphia. See to find out more.
Free the Memes. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About