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!

In reply to Re^2: Including special characters in a search and replace by wudaben
in thread Including special characters in a search and replace by wudaben

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.