Hi,
Unable to remove the ^M character
Having one trigger that should rewrite the file content with copyright statements during check out.
Workout: File doesn't have ^M character prior to check out. It is working fine in solaris view and windows view. Since tried to check out the same file in imported view(the view which is imported from unix to windows), it was added with ^M at end of each line of file content.
Tried to remove the ^M once rewrite done for the copyright statement using tie function in many ways
But didn't get the expected result
File prior to check out:
class Test { public static void main(String[] args) { System.out.println("Hello Test!"); } }
File once check out done in unix view:
vi test.java //**************************************************** // Copyright (c) 2009, Inc. // All rights reserved. //**************************************************** class Test { public static void main(String[] args) { System.out.println("Hello Test!"); } }
File once check out done in imported view(unix style view) in windows:
L:\test>ct co -nc test.java vi test.java //****************************************************^M // Copyright (c) 2009 Systems, 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
Tried in following ways to remove the ^M and was not able to remove the ^M
my @lines; if($imported_view){ print "\nInside IF loop\n"; tie( @lines, 'Tie::File', "$File" ) || die("can't open $File: +$!"); my $size = @lines; my $i; for ( $i = 0 ; $i < $size ; ++$i ) { print "Current Line:$lines[$i]\n"; #$lines[$i] =~ tr/\r\n//d; #$lines[$i] =~ s/\x0D$//g; #$lines[$i] =~ s/0d$//g; #$lines[$i] =~ s/\r\n$//g; #$lines[$i] =~ tr/\cVM//d; #$lines[$i] =~ tr/^$//d; } untie @lines; }
Thanks in advance,
Kavitha
In reply to Unable to remove the ^M character by kkavitha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |