Monks I humbly ask for some help.
I am writing a program that breaks apart files at work, these files are extracts from ARCGIS shape files that have been extracted from the ARCGIS database we have here. The file that I am having trouble with is an attributes file. At this time the only thing I can think of to do is to read the file once to get the record count and then read the file a second time to dump the records out. What I have been running into looks like a memory leak in that my computer starts to run really slow. I am sure it has to do with the while loop that I am running and then with the second read, I'm just not at my best right now and I think I have looped into a corner. I can place more of the code out here if need be. But to keep it short I read in one file to get the file names and then I open each of the filenames with the appropriate extension to start reading the files, the files are all in binary by the way.
binmode AtrFile; # Assign the variables, Base Atr size is 12 $base_readsize = 8; $AtrTmp = "I I"; $bytes_read = read AtrFile, $dat_block, $base_readsize; ($Cksum, $NxIdx) = unpack( $AtrTmp, $dat_block ); # Assign the variables, Base Label size is 20 $LblTmp = "i i b8 b16 b8 i C"; $lbl_readsize = 20; while ($bytes_read = read AtrFile, $lbl_block, $lbl_readsize) { $lbl_readsize = 20; ( $NumLbl, $LblKnd, $ZmLvl, $FntSz, $res, $Lngth, $Ornt ) = un +pack( $LblTmp, $lbl_block ); $num_readsize = $Lngth; $NumTmp = "a" . $Lngth; read AtrFile, $num_block, $num_readsize; ( $LblVal ) = unpack( $NumTmp, $num_block ); $x++; } close( AtrFile ); sleep 1; print( STDOUT "MADE IT HERE AND $iIcao has $x records\n"); # Open Attribute file for reading open( AtrFile, "<$AtrFile" ); binmode AtrFile; # Assign the variables, Base Atr size is 12 $base_readsize = 8; $AtrTmp = "I I"; $bytes_read = read AtrFile, $dat_block, $base_readsize; ($Cksum, $NxIdx) = unpack( $AtrTmp, $dat_block ); print( Type09File "$iIcao Set_Header: $Cksum, $NxIdx\n"); for ( $v = 0 ; $v < $x ; $v++ ) { # Assign the variables, Base Label size is 16 $lbl_readsize = 20; $LblTmp = "i i b8 b16 b8 i C"; $bytes_read = read AtrFile, $lbl_block, $lbl_readsize; ( $NumLbl, $LblKnd, $ZmLvl, $FntSz, $res, $Lngth, $Ornt ) = un +pack( $LblTmp, $lbl_block ); print( Type09File "Label_Header: $NumLbl, $LblKnd, $ZmLvl, $FntSz, $re +s, $Lngth, $Ornt, "); $num_readsize = $Lngth; $NumTmp = "a" . $Lngth; $bytes_read = read AtrFile, $num_block, $num_readsize; ( $LblVal ) = unpack( $NumTmp, $num_block ); print ( Type09File "$LblVal\n"); } # Close data file(s) close( GeoFile ); close( AtrFile ); }
Thanks for the help, Mike

In reply to File Parsing by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.