Trying to benchmark SLURP versus other forms of Perl code

Get error "Substitution loop at c:/strawberry/perl/vendor/lib/File/Slurp.pm line 254

Following code works well to 600MB but over this size error occurs in step 3.

#!usr/bin/perl use strict; use File::Slurp qw( :all); use Time::HiRes qw(gettimeofday tv_interval); # get arguments for process my $tmv0 = [gettimeofday]; my $fl_in = $ARGV[0]; # reading records... step 1 open my $in_fh, '<', $fl_in or die $!; my $s1=<$in_fh>; print "$s1 from $fl_in \n"; my $numin=0; while (<$in_fh>) { $numin++; } close $in_fh; my $tmv1 = tv_interval($tmv0,[gettimeofday]); print " Test Step 1 Found $numin records at $tmv1\n"; ### ### now using whole string... step 2 ### open my $in_fh, '<', $fl_in or die $!; my $text_file = do { local $/; <$in_fh> }; close $in_fh; my $tmv2 = tv_interval($tmv0,[gettimeofday])-$tmv1; my $lenstr=length($text_file); print " Test Step 2 Found $lenstr bytes in $tmv2 seconds\n"; ## ## Now slurp... step 3 ## $numin=0; $text_file = read_file($fl_in); $lenstr=length($text_file); my $tmv3 = tv_interval($tmv0,[gettimeofday])-$tmv1-$tmv2; print " Test Step 3 Found $lenstr bytes in $tmv3 seconds\n";

In reply to SLURP Error 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.