Tim Musson wrote:
>
> hey Perl people!,
Hello,
> Can't seem to get my brain to work this afternoon...
>
> I need to read a file and put it in a $Variable (not @Array).
>
> [snip]
>
> This next bit is my problem. I can use the $body in the bit below,
> but not the @body. Looks like if I put @body as a parm to SendIt()
> above, it comes in a multiples elements of @_ and I get #!perl as the
> body, nothing else.
>
> sub GetBodyFromFile {
> my $file = $0;
> open (INFO, $file);
> @body = <INFO>;
> close(INFO);
> $body="
> 123456789012345678901234567890123456789012345678901234567890123456789012345678
> 1 2 3 4 5 6 7";
> }
>
> So, how do I get the contents of a multi line file in $body?
The easiest way is to change the value of the input record separator.
sub GetBodyFromFile {
my $file = $0;
local( $/, *INFO );
open INFO, $file or die "Cannot open $file: $!";
$body = <INFO>;
close INFO;
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]