my (@newLine) = &AnalyzeFileEol($infile); my $newLine = join("", map { chr(hex($_)) } @newline; local $/ = $newLine; # ------------------------------------------------------------ sub AnalyzeFileEol { my ($file) = shift; my $eol = chr(10); unless (open (FH, "<", $file)) { die "Error: couldn't read file '$file': $!\n"; } # unless my @chars = (); while (defined (my $chr = getc(FH))) { my $hex = sprintf("%02X", ord($chr)); if ($hex eq '0D') { my $next = sprintf("%02X", ord(getc(FH))); if ($next eq '0A') { close (FH); print "Newline format: Dos: $hex $next\n"; return ($hex,$next); } # if else { close (FH); print "Newline format: Mac: $hex\n"; return ($hex); } # else } # if elsif ($hex eq '0A') { close (FH); print "Newline format: Unix: $hex\n"; return ($hex); } # elsif } # while die "Error: couldn't find out file format\n"; close (FH); return; } # AnalyzeFile # ------------------------------------------------------------