My perl skills are self taught so please be gentle. I'm trying to remove the hex character(0C) from the end of a file. My initial strategy was to loop through each line and use regex to search and replace. I think my problem is that the when the last line is read it only includes the string to the LF and ignoring the hex0C that follows. Here's a portion of the code:
This has to be a simple problem. Any ideas?
Thanks in advance.
Code:
my $hdr_file_tmp = $hdr_file.".tmp";
open(HDRFILE, "$file{'raw_gz'}"."$hdr_file") || die "could not open $hdr_file! $!";
open(HDRFILETMP,">>$file{'raw_gz'}"."$hdr_file_tmp") || die "could not open $hdr_file_tmp! $!";
while (my $iline=<HDRFILE>)
{
$iline =~ s/\x0C//g;
print HDRFILETMP $iline;
}
close(HDRFILE) || die "could not close $hdr_file! $!";
close(HDRFILETMP) || die "could not close $hdr_file_tmp! $!";
unlink("$file{'raw_gz'}"."$hdr_file") || die "could not remove $hdr_file! $!";
rename("$file{'raw_gz'}"."$hdr_file_tmp", "$file{'raw_gz'}"."$hdr_file") || die "could not rename $hdr_file_tmp! $!";
This has to be a simple problem. Any ideas?
Thanks in advance.