On Monday, November 25, 2002, at 02:09 PM, Chris Nandor wrote:

In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Slaven Rezic) wrote:

Could this be made even more generic, but translating to \n instead of \012?

Or use source filters:

package Filter::Any2Unix;
Any2Native?
When I had LinuxPPC on my Mac (when Mac OS X was still Rhapsody),
I had written this little module to run my Perl scripts with Mac end-of-lines
under Linux. Not pretty but still functional.

package Eol;
use Carp;

=head1 NAME

Eol - Perl module to execute scripts with foreign end-of-line character

=head1 SYNOPSIS

perl -MEol foo.pl

=head1 DESCRIPTION

This module allow one to execute Perl programs with foreign end-of-line
character. It's primarily intented to be executed on Unix systems as it
must be passed in argument to C<perl>, but it may also work on Win32
systems.

=cut

if($0 ne '-e') {
my $script;

READ: {
local $/;
open(FILE, $0) or croak "can't read file '$0': $!";
undef $/;
$script = <FILE>; ## read whole file
close(FILE);
}

$script =~s@(\015\012|\015|\012)@$/@g;

eval $script;
print $@ if $@

} else {
carp "warning: module Eol can't be used on -e scripts "
}

1;
__END__


S�bastien Aperghis-Tramoni
-- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ]

Reply via email to