tell@oscar.cs.unc.edu (11/13/90)
Heeelllpppp! I've written many lines of good perl code, but this little thing has be completely baffled. I get the same results with PL18 and PL37. I haven't installed PL40 yet. The subroutine below was extracted from a larger program and built into the test program which still fails. The subroutine reads logical lines from a file that are composed of many physical lines; logical lines are broken into physical lines with a '$' at the end of the line, just like make and sh use '\' for line continuation. The symptom is that the subroutine stops reading somewhere early in the file and returns EOF. There are no completely blank logical or physical lines in the file that could be mistaken for "false" in an if, although I think this may be a deficiency in the subroutine. The program always dies at the end of a logical line and is consistent on any given input file. It seems to die somewhere around 2-3000 bytes into the file, somthing less than 100 logical lines, as indicated by the results of tell() on the file added for debugging. Tell() is positioned just before the logical line that should have been read next. Some sample input is included; replicate it several times to create a test file of 300 lines or so. Thanks very much for any help fixing this or suggestions on a new approach... We really need the larger program fixed.... -------------------------------------------------------------------- Steve Tell e-mail: tell@wsmail.cs.unc.edu usmail: #5L Estes Park apts CS Grad Student, UNC Chapel Hill. 919 962 1845 Carrboro NC 27510 -------------------------------------------------------------------- The test program and subroutine #!/usr/local/contrib/bin/perl $net = $ARGV[0]; open($net, $net) || die "can't open $net, aborting"; while($_ = &get_line_cont($net)) { print "$_\n"; } $posn = tell($net); # Try to figure out where we died. print "main: EOF, line=$_, pos=$posn\n"; sub get_line_cont { local($file) = @_; local($nxtline, $thisline, $pos); do { # Same results either way #return $thisline unless ($nxtline = <$file>); if(!($nxtline = <$file>)) { $pos = tell($file); ### this never gets printed print "get_line_cont: EOF, line=$thisline, pos=$pos\n"; return $thisline; } chop($nxtline); ## Dispose of the newline print "nxtline=\"$nxtline\"\n"; ## More debugging $thisline .= $nxtline; } while($thisline =~ s/\$$// ); $thisline; } Some sample input.... .PART LIST PACKAGED .NUMERIC PINS .UNPLACED 74F32 DP $ U9 74F541 DP $ U124 74F74 DP $ U10 BT439 DP $ U11 CERCAP DP $ C696 $ C704 $ C705 $ C706 $ C707 $ C709 RESQTR DP $ R1 $ R2 $ R3 $ R105 $ R109 $ R110 $ R111 $ R112 TANT200 DP $ C10 1N4148 DP $ D30 $ D31 2N3904 DP $ Q2 .ALPHA PINS BT461 DP $ RDACGRN .NUMERIC PINS CAP1206 FP $ C390 $ C391 $ C392 $ C393 $ C394 $ C395 74F377 DP $ U12 $ U13 $ U14 $ U15 RESQTR DP $ R217 $ R218 $ R219 $ R220 RPISO8 DP $ RP115 $ RP116 $ RP117 $ RP118 $ RP119 $ RP120 74F377 DP $ U4 $ U5 $ U6 BT431 FP $ U7 $ U8 RPISO8 DP $ RP121 $ RP122 $ RP123 $ RP124 $ RP125 74F564 DP $ U1 RESQTR DP $ R193 $ R194 $ R195 $ R196 $ R197 $ R198 $ R199 $ R200 $ R201 $ R202 $ R203 $ R204 $ R205 $ R206 $ R207 $ R208 .ALPHA PINS APP4X40 DP $ PBS2 .NUMERIC PINS RPTERM10 DP $ RP58 $ RP59 $ RP60 $ RP61 $ RP62 RESQTR DP $ R146 $ R227 $ R228 $ R229 $ R230 $ R231 $ R232 $ R233 $ R234 $ R235 $ R236 $ R237 $ R238 $ R239 $ R240 1N5908 DP $ D15 $ D16 $ D17 $ D25 $ D26 $ D27 FBPXMUX DP $ P44 $ P45 $ P46 $ P47 $ P48 $ P49 $ P50 $ P51 .EOS