in reply to put file content into a string

The idiomatic construct would be:

open( IN, "<", $file ) or die "Can't open: $file: $!\n"; my $str = do { local $/; <IN> }; close( IN );

See perlvar for more info on $/.