I'm trying to figure out why a script that I've written runs in half a minute under Linux, but takes a half-hour or more under Win32.

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

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.