The concatenation operator in Perl is dot ("."), not plus ("+"). You're evaluating the slurped-in string in numeric context, and presumably it has a value that numerifies to zero. That should handle your first example.
Your second example works for me. And it seems that you are stating that your third and fourth examples do function as you expect. So it's really just the first that's a problem. Use the dot operator for concatenation.
Also in your first example you're not checking for open failure with an "or die $!" clause. That would be a good practice.
Dave
In reply to Re: Contents of a file into a scalar
by davido
in thread Contents of a file into a scalar
by MarkofPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |