John_Kennedy [mailto:[EMAIL PROTECTED]] wrote:
> I have the following script (simplified)
>
> #!/path/to/perl -w
> open LIST,"/path/to/data" or die "/path/to/data: $!";
> open(SENDMAIL, "|/usr/lib/sendmail -oi -t") or die "Unable to
> fork: $!";
> format SENDMAIL=
> From: Me <[EMAIL PROTECTED]>
> To: You <[EMAIL PROTECTED]>
> Subj: Stuff
> blah blah blah
> Thank you,
> Me
> .
> write SENDMAIL ;
> close(SENDMAIL);
>
> I get the following error (no other info is given).
> # ./test.pl
> syntax error at ./test.pl line 6, near "To:"
> Execution of ./test.pl aborted due to compilation errors.
>
Formats don't work like that. They consist of "picture" lines and
"argument" lines, with special characters (like <, |, @, and >) on each
picture line to represent the layout and justification of the individual
fields, and normal Perl expressions on each argument line to serve as the
values for the fields.
So in your example above, Perl is attempting to interpret the "From:" line
as a picture, and the "To:" line as a set of arguments. Since that's not
what they are, you're getting syntax errors. Read the perlform manpage for
all the details:
perldoc perlform
Brett suggested using a here doc instead of formats, and it's a good idea.
Just be careful to escape the "@" signs, or Perl will think "@example" and
"@foo" are array variables, and try to interpolate them into the string.
--Bill
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]