The script loops through a text file containing ~800K variable-length, pipe-delimited records. The first byte of each line identifies record type.
The script copies each line of the source file to one of several destination files, depending on that line's record type ID.
In a Linux environment,the script processes the text file in ~30 seconds. I've tried the identical script under XP Home and Win2K. In both environments, running ActivePerl, the same script takes 30 - 40 minutes. The XP install is on a dual-boot machine with the Linux environment. I tried running the script under Cygwin on the dual-boot machine, but it didn't run any faster.
The obvious solution, for me, is to run the script only under Linux. But it could be useful to colleagues who only have Win32.
I'd be grateful for any tips on writing something that runs faster under Win32.
Code snippet:
#!/usr/bin/perl -w use strict; $|++; open REPORTS, '/home/user/data.txt'; my $record = <REPORTS> ; while ($record = <REPORTS>) { if(substr($record,0,1) eq '1') { open(fileOUT, ">>form_1_record.txt"); print fileOUT $record; close fileOUT; } ... }
The script contains similar if statements for each record type.
Edit: g0n - replaced pre tags with code tags
In reply to ?? Blazes under Linux; crawls under XP & Win2K... by WordWeaver
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |