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

[MacPerl] reading PC files script ??? (fwd)



According to Laurent Bardi:
> hi,
> 
> me again...
> 
> The pb is that we use scripts that are shared by perl-win32 and macperl,
> and macperl is angry when he see pc files....
> 
> I cannot use the $/ in order to tell macperl to change his EOL char
> because we do require of a lots of files that are macperl-native and
> pc-native (a mixed).
> 
> if somebody has an idea ???
> 
> sorry for thoses questions, but it would be a great thing to succeed:
> all unified in perl no matter the OS!!!!

This is actually very easy to get around.  Make a routine.
I'll call it PR.  It should look like this:

sub pr
{
	local( $theReply ) = @_;

	if( $^O =~ /macos/i ){
		$theReply =~ s/\012/\012\015/g;
		}
		elsif( $^O =~ /ibm/i ){
#
#	Modify the reply as needed.
#
			}
		else{
#
#	Do everyone else (which should just be Unix)
#
			}

	print $theReply;
	exit( 0 );
}

Just call this routine instead of trying to remember what
to do for each separate system.  Makes it a lot handier.
All you have to do is:

	&pr( $myReply );

And it is modified and sent back correctly to the server.
All you have to put into $myReply is your regularly
separated lines.  Like this:

	$myReply = "<HTML>\n";
	$myReply .= "<HEAD>\n";

or the more popular:

	$myReply = <<HTML_CODE;
Content-type:	test/html

<html>
<head>
.
.
.
HTML_CODE

Have fun!  :-)

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch