[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Odd behavior on die() (fwd)



According to Danny Thomas:
> IMPORTANT QUESTION
> Is there some way we can encourage the CPAN maintainers to prefer network
> modules making use of \015\012 over \r\n ? As mentioned above, it's not
> just a matter of changing all \n's to \012, and it's better if the
> author/maintainer does this. Do any other perl implementations use unusual
> encodings for \r\n ?

It would probably be better if everyone agreed on using a single variable like $SMTP_EOL, $NNTP_EOL, $FTP_EOL,
and the like.  Then a single replace (or loop replace for arrays in other languages) could be implemented
which would replace all of the standard \n's with the appropriate ending for the line terminator.  An example
would be:

#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
#	End Of Line Variables
#
#	For use with the various system types
#	All entries MUST be made in their octal or hex numbers
#	so that the various systems do not mistake what has to
#	be sent.  No "\r"'s, or "\n"'s or backslash anything
#	is allowed due to each system's representation of
#	these commands being slightly different.
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#	Simple Mail Transfer Protocol (SMTP) End-of-line
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
	$SMTP_EOL = "\015\012";
	$SMTP_NEWLINE = "\n";
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#	File Transfer Protocol (FTP) End-of-line
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
	$FTP_EOL = "\015\012";
	$FTP_NEWLINE = "\n";
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#	Network News Transfer Protocol (NNTP) End-of-line	
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
	$NNTP_EOL = "\015\012";
	$NNTP_NEWLINE = "\n";
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#	Hyper Text Mark-up Language (HTML) End-of-line
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
	$HTML_EOL = "\015\12";
	$HTML_NEWLINE = "\n";

*************************************************************

Then all you have to do is to remember to do the following:

	$theReply = <<HTML_CODE;
Content-type: text/html

<html>
<head>
<title>
My Title
</title>
</head>

<body>
This is a test.
</body>
</html>
HTML_CODE

	$theReply =~ s/$HTML_NEWLINE/$HTML_EOL/g;
	&MacPerl::Reply( $theReply );
	exit( 0 );