Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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

Replies are listed 'Best First'.
Re^2: Regex Split and Formatting
by gnosti (Hermit) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026881]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2017-11-18 07:26 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (277 votes). Check out past polls.