http://www.perlmonks.org?node_id=476515


in reply to Re: Regular expressions
in thread Regular expressions

That's an aweful way of reading a file. It means every line must be pushed onto the stack. The OP's method was better, and the following is even better because it avoids a call to stat and works will all kinds of IO handles:

my $text; { local $/; $text = <DATA>; }

Visually, I prefer
my $text = do { local $/; <DATA> };
but I think I determined the above is equivalent to
my $text; { local $/; my $temp = <DATA>; $text = $temp; }