Welcome to the Monastery!

What have you tried? The Monks here usually like to see a good faith effort*, even if the code fails horribly. :-) The following might help to get you started:

  1. use strict and warnings
  2. declare two arrays (my)
  3. open the input file
  4. read a line from the input file (see "I/O Operators" in perlop
  5. remove the newline from each line (chomp)
  6. split the line on the comma
  7. push the values from the line onto the appropriate array (I'm not sure what you meant by 'without the "+" sign'... replace it with something else or remove it entirely?)

Give it a try, and feel free to come back when you get stuck.

*Chances are, though, that another Monk will give you a fully working solution that you can use almost as-is. If you use it, take the time to learn how it works - you'll benefit from it more in the long run.


In reply to Re: Read from file to two arrays. by bobf
in thread Read from file to two arrays. by Offshore_Worker

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.