"Sumit Babu" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello All,
>
>      I will be getting the files from different platforms (i.e. Unix or
> Windows). Is there a way i can automatically detect the line endings and
> accordingly use the chomp function to remove it.

Here is some code I saw reading in CGI.pm awhile ago. I imagine that you
could put it in a sub and return $CRLF and then in some circumstances know
what the OS's record seperator is. Im just guessing and this probably isnt
how I'd do it. Refer to the CGI.pm source for more info.

unless ($OS) {
    unless ($OS = $^O) {
 require Config;
 $OS = $Config::Config{'osname'};
    }
}
if ($OS =~ /^MSWin/i) {
  $OS = 'WINDOWS';
} elsif ($OS =~ /^VMS/i) {
  $OS = 'VMS';
} elsif ($OS =~ /^dos/i) {
  $OS = 'DOS';
} elsif ($OS =~ /^MacOS/i) {
    $OS = 'MACINTOSH';
} elsif ($OS =~ /^os2/i) {
    $OS = 'OS2';
} elsif ($OS =~ /^epoc/i) {
    $OS = 'EPOC';
} else {
    $OS = 'UNIX';
}

and then later it says:

$EBCDIC = "\t" ne "\011";
if ($OS eq 'VMS') {
  $CRLF = "\n";
} elsif ($EBCDIC) {
  $CRLF= "\r\n";
} else {
  $CRLF = "\015\012";
}




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to