Tried the same in the following.
FIRST Try:
tie( @lines, 'Tie::File', "$File" ) || die("can't open $File: $!");
local $/ = "\r\n";
chomp @lines;
untie @lines;
SECOND Try:
my $content = "";
open IFILE, "$File" or die $!;
while (<IFILE>) {
$_ =~ s/\r//g;
$content .= $_;
}
close(IFILE);
open OFILE, ">$File" or die $!;
print OFILE $content;
close(OFILE);
But it is not removing the ^M. After executing the above, I am seeing the ^M in vi Editor:
"test.java" 12 lines, 333 characters
//****************************************************^M
// Copyright (c) 2009, Inc. ^M
// All rights reserved. ^M
//****************************************************^M
^M
class Test ^M
{^M
public static void main(String[] args) ^M
{^M
System.out.println("Hello Test!");^M
}^M
}^M