As a new user of Perl, you'll want to look up the documentation for each part of the task; the Anonymous Monk gave you links to some of the commands you'll need; each of those documents includes code snippets that show how to use them. If I were you, I would make a programming-language-agnostic outline of what needs to be done ("open input file, open output file, read input file one line at a time, for each line do something including writing to the output file"). Then delve into the documentation to try to figure it out what commands you need to perform those tasks. The perlintro that AM linked should help you with your question of how to get something into a variable. Once you've got example code, if it doesn't work, post a SSCCE which shows your code, a simple input file (smaller is better, as long as it's sufficient to show the problem), an example of what you'd like the output file to look like, and let us know what's going wrong and/or what errors you are seeing.


In reply to Re: how to read variables from a file and write to a new file? by pryrt
in thread how to read variables from a file and write to a new file? by taha95

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.