Tip #1 from the Basic debugging checklist: warnings. I get this when I run your first example:
Argument "\n" isn't numeric in addition (+) at ...
I think you are enforcing numeric context by using + in your print. This works for me:
print $string, "\n";
And remember... Slurp it good :)
In reply to Re: Contents of a file into a scalar
by toolic
in thread Contents of a file into a scalar
by MarkofPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |