> > It seems that increasing the buffer more thant 1024 didn't help in all > > cases. It seems that this stream of data comes in several packets and the > > terminator string is !END! > > I've tried reading one byte at a time, using an $i as offset, and checking > > whenever the END pattern showed up > > > > my $buffer; > > $i=1; > > while($buffercomplete=~/END/){ > > Don't you want !~ instead of =~ ?
You are completely right. I've changed for !~ and now it reads something. > > > $bytes = sysread ($handle, $buffer, 1,$i); > > $buffercomplete=$buffercomplete.$buffer; > > $i++; > > } > > return $buffer; > > > > but it doesn't read a line, > > What is in $i after the read ? What should it be ? The $i reaches the number 57, before hanging. It seems that well before reaching the !END! string it reads some char undef or something. > > whereas: > > > >>>my $buffer; > >>>my $bytes = sysread ($handle, $buffer, 1024); > >>>if (not defined $bytes or $bytes < 0) { > >>>#err > >>>print "error!!!"; > >>>} elsif ($bytes == 0) { > >>># EOF > >>>} > >>>return $buffer; > > > > does read seven lines, and increasing the 1024 to 8192 the reading is the > > same, and it does not include the !END! pattern > > I don't follow what you're saying here. If you're not getting the > EOR indicator, try a bigger read or read a second time if you don't > get it in the first buffer. Do a select before the read if you > don't want to block. How much data do you get on the first read ? > How big is the full record supposed to be ? > > Please don't CC me on your replies. I have several questions here: I don't know what the EOF indicator should be. I don't know how to read a second time, do I have to do select($handle) and then sysread again? What is to block? In the first read I get: ^BF^D3765,4443734 !APID3765 ^F^,938252,2 ,1386.25 ,FILL746419490 ,,| ^F^,938263,1 ,1385.75 ,FILL746428495 ,,| ^F^,938335,1 ,1386.25 ,FILL746498613 ,,| ^F^,938969,1 ,1385.50 ,FILL7471301676 ,,| ^F^,938972,1 ,1385.50 ,FILL7471331679 ,,| ^F^,939684,3 ,1389.50 ,FILL7478422788 ,,| ^F^,939684,1 ,1389.50 ,FILL7478422789 ,,| ^F^,939704,2 ,1754.75 ,FILL7478622814 ,,| ^F^,939704,1 ,1754.75 ,FILL7478622813 ,,| ^F^,939704,1 ,1754.75 ,FILL7478622812 ,,| It lacks 3 or 4 lines. _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs