Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Regex Split and Formatting

by topher (Scribe)
on Apr 03, 2013 at 17:05 UTC ( #1026881=note: print w/ replies, xml ) Need Help??


in reply to Regex Split and Formatting

*Update* : Oh yes .. I forgot to mention.. i'm not allowed to use any modules..

Parsing CSV isn't your real problem; this is your real problem.

CSV is one of those things that seems simple and easy to handle at first glance. But, once you start digging in and coming across corner-cases, you realized it can be very tricky to get right. You mention the embedded newlines, but what about embedded commas (commas inside quoted fields)? Are all fields quoted? Can you guarantee that? What about escaped quotes inside of quoted fields?

Unless this is a homework assignment, or you have strange desire to reinvent the wheel (in which case you should be reviewing the code in existing CSV modules), you would be better off copying and pasting Text::CSV into your program than you would be in trying to recreate it.

Christopher Cashell


Comment on Re: Regex Split and Formatting
Re^2: Regex Split and Formatting
by gnosti (Friar) on Apr 03, 2013 at 17:17 UTC
    Funny, that when people post saying "I'm not allowed to use modules", I almost never hear them say why.

      I was thinking the exact same thing. I'm not going to say that there are no valid reasons or situations where modules aren't allowed, but it's very hard to think of one that doesn't involve, "because I'm supposed to write this functionality myself as homework".

      worst-case scenario, you can almost always bundle the modules into your own application, or utilize modern tools like App::FatPacker to do the work for you.

      Programming in Perl without CPAN is like going into a gun fight without bullets.

      Christopher Cashell

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026881]
help
Chatterbox?
and the web crawler heard nothing...

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

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





    Results (105 votes), past polls