info-cvs
[Top][All Lists]
Advanced

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

Re: DOS2UNIX conversion Tool


From: Derek Robert Price
Subject: Re: DOS2UNIX conversion Tool
Date: Fri, 07 Nov 2003 13:45:55 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lars Thuring wrote:

| address@hidden wrote:
|
|>> Looking for DOS2UNIX Tool execution while checkin the files, can any
one help on this.
|>
|>
|>
|> For unix, there is "flip".
|
|
| There is also "dos2unix" for Unix / Linux:


The following perl script should convert Mac and DOS text files to use
UNIX line endings:


#! /usr/bin/perl -w

use strict;
use IO::File;

my $filename;
my $file;
my @lines;
my $line;

# Open stdin and stdout if no files are specified...
unshift @ARGV, "-" if ( !scalar ( @ARGV ) );

while ($filename = shift)
~        {
~        if ( !( $file = new IO::File "<$filename" ) )
~                {
~                warn "Couldn't open $filename for read: $!";
~                next;
~                }
~        @lines = $file->getlines;
~        if ( !( $file = new IO::File ">$filename" ) )
~                {
~                warn "Couldn't open $filename for write: $!";
~                next;
~                }
~        foreach $line ( @lines )
~                {
~                $line =~ s/\r\n?$/\n/g;
~                $file->print ( $line );
~                }
~        }

exit 0;

- --
~                *8^)

Email: address@hidden

Get CVS support at <http://ximbiot.com>!
- --
Man who live in glass house dress in basement.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Using GnuPG with Netscape - http://enigmail.mozdev.org

iD8DBQE/q+hiLD1OTBfyMaQRAoeuAJ9jqc5bP8DcEEw1FiB1hxTCSqqPkgCeLDGl
NEmjZxr7yYw2oUQ5SlUEMeI=
=sMyu
-----END PGP SIGNATURE-----






reply via email to

[Prev in Thread] Current Thread [Next in Thread]