This looks fishy, Cliff. The output shows that rcols is reading a *lot* of columns in the $/ version, and not just two.
I would suggest avoiding $_ in the while loop and use an explicit string assignment to avoid possible overwrites. Second, run under the debugger and put a break on the $fhline = <$fh> in the rcols routine to see if that makes sense. Good luck, Chris On 6/28/12, Clifford Sobchuk <[email protected]> wrote: > Hi Folks, > > I am reading in a file in paragraph mode to suck in records that I parse out > identifier information and then setting that record to a file handle (at > least I think I am doing it correctly), and then using this as the file > handle for rcols to suck in the data using an INCLUDE statement. > > However, I am not getting the data even though it indicates that it is > reading the correct number of data points. > > Here is the code that I am using and some sample data. > > ******* Read in Paragraph Mode ************ > > pdl> $/ = "=====\n" ; # Set the input record separator for paragraph mode > pdl> open $fh, "<", "test.txt" or die "can't open test.txt\n" ; # open a > filehandle in paragraph mode > pdl> while (<$fh>) { print $_; print "\nnext\n"; } # Verify that records are > being brought in as expected. > > Attribute Name: Sector Receive Power > TimeStamp: 2000/06/27-20:02:20.930 > Source Node Id: 0x00806050 > > MO Instance: 2 > Count: 20 > > Ant 0 Rx Pwr Ant 1 Rx Pwr (1/16 dBfw) > 191 182 > 190 180 > 190 181 > 189 181 > 187 180 > 186 179 > 184 177 > 185 177 > 188 180 > 190 182 > 186 179 > 185 179 > 185 179 > 184 178 > 184 178 > 186 179 > 193 181 > 196 182 > 190 180 > 187 179 > > ===================================================== > > next > > ******* Try in memory file handle for rcols: Attempt #1 ************ > > pdl> close $fh ; # Close the file handle to reset > pdl> open $fh, "<", "test.txt" or die "can't open test.txt\n" ; #Re-open > filehandle - still in paragraph mode. > > pdl> while (<$fh>) { > open $rcol, "<", \$_ or die "can't open stream\n"; #create an in memory file > handle for rcols > ($rx0, $rx1) = rcols $rcol, { INCLUDE => '/\s+\d+\s+\d+/' }; # pull out the > data elements > close $rcol; } # close the file for the next open. > > GLOB(0xafc73f4)Reading data into piddles of type: [ Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double ] > Read in 1 elements. > Reading data into piddles of type: [ Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double ] > Read in 1 elements. > Warning: rcols() did not read in any data. > pdl> p $rx0 > Use of uninitialized value $_[0] in print at (eval 352) line 5, <> chunk > 34. > pdl> p $rx1 > Use of uninitialized value $_[0] in print at (eval 352) line 5, <> chunk > 34. > > > ******* Try in memory file handle for rcols: Attempt #2 ************ > > pdl> close $fh; #start again > pdl> open $fh, "<", "test.txt" or die "can't open test.txt\n" > pdl> while (<$fh>) { > open $rcol, "<", \$_ or die "can't open stream\n"; > ($rx0, $rx1) = rcols $rcol, { INCLUDE => '/\s+\d+\s+\d+/' }; > print "$rx0, \t $rx1\n"; # try printing out the values since I am not > appending. > close $rcol; } > > Reading data into piddles of type: [ Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double ] > Read in 1 elements. > [0], [0] > Reading data into piddles of type: [ Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double Double Double Double Double > Double Double Double Double Double Double Double ] > Read in 1 elements. > [0], [0] > Warning: rcols() did not read in any data. > Use of uninitialized value $rx0 in concatenation (.) or string at (eval 458) > line 5, <> chunk 1. > Use of uninitialized value $rx1 in concatenation (.) or string at (eval 458) > line 5, <> chunk 1. > > > Any ideas on what I am doing wrong? The data files that I will be parsing > are larger than my memory so I am trying to chunk it down and use append/cat > to grow the pdls to conserve memory. > > Thanks, > > > > CLIFF SOBCHUK > Ericsson > Core RF Engineering > Calgary, AB, Canada > Phone 613-667-1974 ECN 8109 x71974 > Mobile 403-819-9233 > [email protected] <mailto:[email protected]> > yahoo: sobchuk > http://www.ericsson.com/ > > "The author works for Telefonaktiebolaget L M Ericsson ("Ericsson"), who is > solely responsible for this email and its contents. All inquiries regarding > this email should be addressed to Ericsson. The web site for Ericsson is > www.ericsson.com." > > This Communication is Confidential. We only send and receive email on the > basis of the terms set out at www.ericsson.com/email_disclaimer > <http://www.ericsson.com/email_disclaimer> > > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
