Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

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!
  • 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, 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
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (5)
    As of 2014-12-20 16:10 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (96 votes), past polls