in reply to Re: Re: Fast reading and processing from a text file - Perl vs. FORTRAN
in thread Fast reading and processing from a text file - Perl vs. FORTRAN

I haven't analyzed your code real closely, but this part sticks out as something that might be optimized:
if ( ($in =~ m/^0\s+(.+?)\s+SUBCASE/) || ($in =~ m/^0\s+(. ++?)\s+SUBCOM/) || ($in =~ m/^0\s+(.+?)\s+SYM/) || ($in =~ m/^0\s+(.+? +)\s+SYMCOM/) || ($in =~ m/^0\s+(.+?)\s+REPCASE/) ) {
Regexes tend to do alot better on fixed strings, and especially on strings which are anchored to the beginning. So what I might try is:
# Give up right away if we don't find '0' at the beginning if ( ($in =~ /^0/) && ( $in =~ /SUBCASE/ or $in =~ /SUBCOM/ or ...)) {
Or you might try to combine your key strings:
if ( ( substr($in, 0, 1) eq '0' ) and ( $in =~ /\b(?:SUB|REP)(?:CASE|C +OM)/ or ... ) {
For one thing looking for SYM and then SYMCOM is redundant and a waste of time, unless you want a '\b' after the strings.

You might try the study function before doing the above regexes, it may or may not help. Try using the Benchmark module to see what is best on your data.

Update: And looking again, its probably the next section that needs the most help...