in reply to Optimizing perl code performance

Perl's core modules include 'Memoize', which attempts to make functions faster by "trading space for time."

http://perldoc.perl.org/Memoize.html

But I'd have to do trial-and-error to see what worked. (I'm wondering if a regExp would be faster than split)
/.*,.*,.*,.*,.*,.*,.*,.*,(*),.*/ my $X = $1
Then you wouldn't even need to call chomp. (And in general, I'm wondering if it would speed things up to combine the other instructions.)
chomp( my($line)=$_ ) ;
UPDATE: It occurred to me that the code re-declares every variable again on every pass through the loop. It seems like it might help to try
my ($X, $Y, $A, $B, $C, $D); while(<DATAIN>)

Replies are listed 'Best First'.
Re^2: Optimizing perl code performance
by QM (Parson) on Aug 17, 2015 at 09:33 UTC
    I'm wondering if a regExp would be faster than split.
    split takes a regex, so an optimized regex similar to the split could only be marginally better, and potentially much worse, especially for simple cases like this.

    Likewise chomp is very simple, and is probably zillions of times faster than IO.

    Profile, then fiddle. Lather, rinse, repeat.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of