Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Not to be rude, but your friend sounds like he just discovered regular expressions last week and he's still unsure about what all the characters do, so he's trying to avoid using the tricky ones. The pipe character, like many other punctuation characters, is a special character in regex patterns, so you must escape it. For instance:

my @fields = split /,/; # split on commas my @fields = split /\|/; # split on pipes

That's all, no big deal. However, as hbd said, unless this is a one-time task with data you're very familiar with, you should use Text::CSV and tell it that your delimiter is the pipe character. That way, when you inevitably run into data containing a quoted delimiter in one of the fields even though you were sure that would never happen, the module can handle it correctly.

Aaron B.
Available for small or large Perl jobs; see my home node.

In reply to Re: Reading File and Seperating into columns by aaron_baugher
in thread Reading File and Seperating into columns by Jalcock501

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 (0=?node_id=237057 ;; 1=Where should I post X? ;; 2=) if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
    • (0=?node_id=341118 ;; 1=How do I compose an effective node title? ;; 2=)
    • (0=?node_id=174051 ;; 1=How do I post a question effectively? ;; 2=)
    • (0=?node_id=674668 ;; 1=Markup in the Monastery ;; 2=)
  • Posts may use any of the (0=?node_id=29281 ;; 1=Perl Monks Approved HTML tags ;; 2=):
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, 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! (0=?node_id=43037 ;; 1=What shortcuts can I use for linking to other information? ;; 2=)
  • See (0=?node_id=17558 ;; 1=Writeup Formatting Tips ;; 2=) and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (12)
    As of 2016-08-25 17:55 GMT
    Find Nodes?
      Voting Booth?
      The best thing I ever won in a lottery was:

      Results (361 votes). Check out past polls.