how to match '\r\n' in dos environment

From: Liang (leo2002chen_at_hotmail.com)
Date: 08/27/04


Date: Fri, 27 Aug 2004 18:54:54 +0800

hi,

I want to convert a file from dos formate to unix format. This is very easy
in unix. But in dos environment, the script can't work.

The perl version I used is:5.001.

Anyone knows the clue? thanks in advance,

open(INPUT, "<$opt_f");
rename( $opt_f, "$opt_f.bak") || die "Unable to rename $opt_f\n$!\n";
open(OUTPUT, ">$opt_f");
while(<INPUT>) {
 if ( s/\r\n/\n/ ) {
    $linesFixed++;
 }
 print OUTPUT;
}



Relevant Pages

  • Re: how to match in dos environment
    ... > I want to convert a file from dos formate to unix format. ... But in dos environment, the script can't work. ... You need to binmode the OUTPUT filehandle, ...
    (comp.lang.perl)
  • Re: how to match in dos environment
    ... > Liang wrote: ... >> I want to convert a file from dos formate to unix format. ... > Gunnar Hjalmarsson ...
    (comp.lang.perl)
  • Re: Why wont this script run??
    ... Try dos2unix to convert the file from a Windows formt to a UNIX format. ... I agree with the above about getting the offical copy of the inet script for ... > Ben Stringer wrote: ...
    (Fedora)
  • Re: Troi Activator Plug-In Question
    ... not yet updated all of its plugs to use the Unix format as opposed to ... I have Troi activator plug-in. ... into the file and machine that will be activating the script. ... I am wondering if I have a file path problem in the "Schedule It" ...
    (comp.databases.filemaker)
  • Re: Iptables not starting
    ... I have a sample configuration script. ... > $ file foo ... ASCII text, with CRLF line terminators ... the script needed to be in unix format. ...
    (linux.redhat)