I have a registry file already decoded in Unicode, I need to replace a value within that file and implement a search and replace...but I keep getting the original file contents instead of the expected result that I am aiming.
$Profile="C:\\registry.reg"; # unicode file $Param="Name"; open (FILE, "<:encoding(UTF-16)", $Profile); @Lines = <FILE>; open FILE, ">$Profile" or die $!; @Lines = <FILE>; close(FILE); foreach $Lines (@Lines) { if ($Lines =~ m/HKEY_LOCAL_MACHINE\\SOFTWARE\\$Param/g) { @LinesSub = split(/\\/,$Lines); $Lines =~ s/$Temp/$Param/g; } print FILE "$Lines"; } close(FILE);
When the file is converted to Ansi manually, the value of the parameter is changed. But I need to make the script do that. I cant seem to change the original (Unicode) file after updating the value from search and replace with the script that i have. It keeps giving me this garbage strings.
I appreciate your help, thanks in advance...
In reply to convert a Unicode file to Ansi, using filehandle.. by nico7nibor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |