Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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]
[james28909]: cant seem to make it look in linux module path for
[james28909]: no matter how i prepare the paths. oh well. looks like ill just have to start wsl perl from scratch
[Corion]: james28909: You can get a list of all modules on your Windows Perl via the autobundle command in the cpan shell. But that likely lists many more modules than you actually want. I recommend a clear separation and installing modules on ...
[Corion]: ... both Perls separately. I use cpanfiles or Makefile.PL for that - listing all modules for an application there allows me to install them via cpanm . or cpan . automatically without any further interaction

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2018-05-23 17:19 GMT
Find Nodes?
    Voting Booth?