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

[MacPerl] reading PC files script part 2 (fwd)



According to Laurent Bardi:
> 
> Is there a way to tell macperl thet $/= eol-pc OR eol-mac ????
> i mean switching from eol-pc to eol-mac and vice-versa is not
> possible...

Ok - how about this:  Make a program which chooses which
set of functions to use dependent upon what type of
computer the person has?  In this scenario you would have
three sets of functions.  One with PC line endings, one
with Mac line endings, and one with Unix line endings.
Then all you'd have to do is to check for the proper OS via
the $^O and act accordingly.  Where you would change this
is the @INC array.  (If I remember my MacPerl/Perl
correctly.)

What I am thinking of is something like:

../../../PCLIB
../../../MACLIB
../../../UNIXLIB

Your function would just contain something like:

sub getOS
{
	if( $^O =~ /macos/i ){
		$INC[++$#INC] = "../../../MACLIB";
		}
		elsif( $^O =~ /ibm/i ){
			$INC[++$#INC] = "../../../PCLIB";
			}
		else {
			$INC[++$#INC] = "../../../UNIXLIB";
			}
}

You call it once at the beginning of each program and it
selects the proper library each time.

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