in reply to Re: Including special characters in a search and replace
in thread Including special characters in a search and replace

I think you've got it pretty much covered Chady and Caron.

The lines are a section of hex from a Windows registry file & the 39's are the first four digits of a user's access code to use a specific color laser printer. I'm reading a code in based on username and trying to replace the four 9's with each user's specific code.

The fact that it's on multiple lines is definately part of my problem. I also was trying to escape my \n characters as well. I didn't realize I could each value without specifying the whole line. Here is my finished output:

#!/usr/bin/perl open (USERS, "user.txt") or die "Cannot open file user.txt: $!\n"; @users = (<USERS>); close USERS; foreach (@users){ chomp; ($userid,$acode) = split/\|/; if ($userid eq $ENV{"USERNAME"}) { @fields = split //, $acode; open(REG, "template.reg") or die "Cannot open file template.re +g: $!\n"; @hex =(<REG>);; close(REG); open(NEWREG, "> import.reg") or die "Cannot open file import.r +eg: $!\n"; foreach $line (@hex){ my $i = 0; $line =~ s/,39,/,3$fields[$i++],/g; print NEWREG "$line"; } close(NEWREG); } }


Thanks for the assistance!