# assuming INFILE and OUTFILE are already open, # and string variables are already set... my $match = $old_username . "\x00"x(84-length($old_username)) . $old_password . "\x00"x(84-length($old_password)); my $replace = $new_username . "\x00"x(84-length($new_username)) . $new_password . "\x00"x(84-length($new_password)); $/ = undef; my $filedata = ; $filedata =~ s/$match/$replace/; print OUTFILE $filedata;