You can do all of that in one line...
my $var = do { local $/ ; <> }; [download]
In reply to Re^3: Need help with Piping by jasonk in thread Need help with Piping by moroshko