in reply to Matching data in a big file

You can slurp the file in one go by unsetting the special variable $/:

{ local $/; $document = <RTF_FILE>; }

Replies are listed 'Best First'.
Re^2: Matching data in a big file
by roboticus (Chancellor) on Dec 14, 2013 at 16:57 UTC

    hdb:

    Lately, I've just been using:

    $document = join("", <RTF_FILE>);

    Compared to the localize technique, I find it clear and easy to type. It is, however, very inefficient. It's fast enough, though, that until today I had never noticed the time it takes to load the file. Will I continue to use the join version? Certainly--except for a task where I need to slurp enough files where it would make a significant difference.

    Just because I have it, here's the benchmark code & results. (You don't have to open it, the results are that File::Slurp and the local technique are roughly equivalent, and both are 10 times faster than the join version.)

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      Thanks roboticus for your useful comparison.

Re^2: Matching data in a big file (slurp without $/)
by Anonymous Monk on Dec 14, 2013 at 13:36 UTC

    slurp without $/

    use Path::Tiny qw/ path /;
    my $document = path( "file" )->slurp;
    $document = path( "file" )->slurp_raw;
    $document = path( "file" )->slurp_utf8;
    $document = path( "file" )->slurp( {binmode => ":raw"} );