in reply to Re: Problem with reading the total file into variable
in thread Problem with reading the total file into variable

seems nobody proposed it so here is a way to do it

{ local $/;#makes the separator variable undef #thus preventing perl from seeing \n as line separators while(<$fh>){ $var = $_; } }

this should read the whole file in one go into $var if I'm not mistaken

Replies are listed 'Best First'.
Re^3: Problem with reading the total file into variable
by Anonymous Monk on Aug 25, 2015 at 08:21 UTC

    seems nobody proposed it so here is a way to do it

    perlintro and Modern Perl both discuss this

    They also avoid a loop to slurp a file

      OOps sorry, I am still learning my way through the nodes I'll delete my redundant previous redundant post