--- Stevan Little wrote: > Howdy all, > > While writing some new Pugs examples I came across another file reading > bug having to do with laziness. When a list is slurped from a > filehandle, then the file closed before the list is accessed, the list > seems to be empty. I believe this is because of how lazily Pugs > creates/evaluates the array. Here is the test I wrote (it is in > t/builtins/io/io.t): > > my $in7 = open($filename); > isa_ok($in7, 'Handle'); > my @lines7 = readline($in7); > ok($in7.close, 'file closed okay'); # << this is where the trouble > begins. > > is([EMAIL PROTECTED], 4, 'we got four lines from the file (lazily)'); > is(@lines7[0], "Hello World\n", 'readline($in) worked in list context'); > is(@lines7[1], "Foo Bar Baz\n", 'readline($in) worked in list context'); > is(@lines7[2], "The End\n", 'readline($in) worked in list context'); > is(@lines7[3], "... Its not over yet!\n", 'readline($in) worked in list > context');
In case you missed it, this issue was discussed in detail on p6l around March 14. The ensuing p6l discussion about whether = should be lazy or eager was triggered by the Pugs bug you just noticed I think: http://groups-beta.google.com/group/perl.perl6.compiler/browse_frm/thread/2aca524a1203cd41/912bea4d0d05554a?q=surprised#912bea4d0d05554a /-\ Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com