I am having a hard time getting this started.

To explain further what I want to do, I currently have 1 file with a list of email addresses. These I am trying to use as my variables. I have another text file where I need to search for "email=john.edu" and replace with email=new_address.edu. Then I would like to save this file with the changes as new_address.txt. I have 100 email addresses in my list. I would like this process to repeat until the end of the adresses. I should have 100 new text files in this directory.

I am new to perl and really do not know where to start. I don't know how to read in my email list and search to replace just the new email address and save the entire file before continuing with the loop.

open (FILEHANDLE, "<$john.txt"); #open main file open (DATA, "<email_list.txt"); @lines = <DATA>; $/ = "\"; while (<DATA>) { #PROCESS AND UPDATE A RECORD }
If you can think of a better way to do this, please let me know. Thanks!!!!

In reply to Re: Re: Search and replace by rscott212
in thread Search and replace by rscott212

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.