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

Lazyness and IO

From:
David Formosa
Date:
July 29, 2005 22:08
Subject:
Lazyness and IO
Message ID:
slrndekuuf.600.dformosa@dformosa.zeta.org.au
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://nntp.perl.org",: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;

say($news,"listgroup");

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
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About