I'm taking a line from a file, and the information taken from the file is currently stored in an array. Just one line is an element.

Now, I would like to take a line, and separate two things with a comma from a file. One being one variable and the other, another variable. Kind of like so:

DomainName, IPAddress DomainName2, IPAddress2

If I'm storing this information in a file that is being read, what is the best way to separate them so I may match IPs I capture in my program to the IPAddresses in my file and then print the DomainName (from my file) that goes with said IP?

I've been told split is a great way to do this but I'm not sure how and just looking at the generic way to use it from Google results isn't going so well for me. Thank you for reading in advance!


In reply to To Split or Not to Split by burningredmoon

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.