in reply to Restriction on getting multiline data into a string

By setting $/ to a reference to an integer, you can control how many bytes are read in each use of the diamond operator.

local $/ = \65536; my $scalar = <FILE>; print length $scalar; # prints 65536 (assuming :raw)

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
Wanted!

Replies are listed 'Best First'.
Re: Re: Restriction on getting multiline data into a string
by bart (Canon) on Nov 19, 2003 at 10:35 UTC
    In the risk of stating the obvious, I'd like to point out that this is documented in perlvar (search for the section for "$/"). I recall that this is a fairly new addition to Perl, but at least, it is documented to work for perl 5.005_03. So it's not that recent. :)
Re^2: Restriction on getting multiline data into a string
by strictvars (Sexton) on Apr 13, 2005 at 15:33 UTC
    Thanks for the tip below. ++
    local $/ = \65536;