> {...} not sure what os original files were on.
In that case, I would strongly suggest not treating these files as text - which is what you're doing with 'while(<INFILE>)' (which reads from the filehandle one "line" at a time - the definition of 'line' being determined by the value of $/.)
You've mentioned that these files are binary. To me, that suggests that they have some kind of structure. If so, you'd probably be better off either parsing them and modifying only the part that you want (assuming you know the data structure) or slurping the entire file as a string - assuming that they're a relatively small proportion of your memory size - and modifying the string. Something like this, maybe:
#!/usr/bin/perl -w use strict; open my $Link, "linkfile.txt" or die "linkfile.txt: $!\n"; while (<$Link>){ next if $. == 1; # Skip the first line chomp; my ($infile, $labno, $out, $anonno) = split /\t/; print "Anonymizing $infile\n"; open my $In, $infile or die "$infile: $!\n"; binmode $In; my $content = do { local $/; <$In> }; close $In; $content =~ s?B27-\d{1,3}?B27-$anonno?gsm; open my $Out, ">", $out or die "$out: $!\n"; binmode $Out; print $Out $content; close $Out; }
In reply to Re: end of line help
by oko1
in thread end of line help
by p789123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |