R
richardkreidl
I need to remove Carriage returns and blank lines from a text file. The
CR works ok, but I'm not sure how to remove blank lines.
This command line works: perl -i -pwe `$_="" unless /\s/' filea...
fileb
I would like to use it in my script below.
#!/opt/perl/bin/perl
open(IN,"Input.txt") || die("Can't open file");
open(OUT,">Output.txt") || die("Can't open file");
while(<IN>) {
chomp;
$text=<IN>;
$text=~ s/[\r]//gs;
print OUT $text
}
close(IN);
close(OUT);
CR works ok, but I'm not sure how to remove blank lines.
This command line works: perl -i -pwe `$_="" unless /\s/' filea...
fileb
I would like to use it in my script below.
#!/opt/perl/bin/perl
open(IN,"Input.txt") || die("Can't open file");
open(OUT,">Output.txt") || die("Can't open file");
while(<IN>) {
chomp;
$text=<IN>;
$text=~ s/[\r]//gs;
print OUT $text
}
close(IN);
close(OUT);