With my oneliners I often want to fetch a whole file inside a string. With only core modules the only solutions I know considering $file = 'foo'
are:
$str = do {local $/; open $fh, '<', $file; <$fh>};
Or
$str = qx{cat $file};
The second method is shorter to write, easier to understand, but involves a lot more complexity behind the curtain (sys_execve).
Is there any better way or a nice sugar that I don't know?