10 May 2016 17:44:57 UTC
- Distribution: Text-CSV-Easy
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (626 / 0 / 33)
- KwaliteeBus factor: 0
- 81.95% Coverage
- License: perl_5
- Perl: v5.10.0
- Activity24 month
- Download (6.16KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- SEE ALSO
- COPYRIGHT AND LICENSE
Text::CSV::Easy_PP - Easy CSV parsing and building implemented in PurePerl
use Text::CSV::Easy_PP qw(csv_build csv_parse); my @fields = csv_parse($string); my $string = csv_build(@fields);
Text::CSV::Easy_PP is a simple module for parsing and building CSV lines. This module is written in PurePerl. For a faster alternative, see Text::CSV::Easy_XS. Either way, you should just be able to use Text::CSV::Easy directly and it will determine which version to use.
This module conforms to RFC 4180 (http://tools.ietf.org/html/rfc4180) for both parsing and building of CSV lines.
- 1. Use commas to separate fields. Spaces will be considered part of the field.
abc,def, ghi => ( 'abc', 'def', ' ghi' )
- 2. You may enclose fields in quotes.
"abc","def" => ( 'abc', 'def' )
- 3. If your field contains a line break, a comma, or a quote, you need to enclose it in quotes. A quote should be escaped with another quote.
"a,b","a\nb","a""b" => ( 'a,b', "a\nb", 'a"b' )
- 4. A trailing newline is acceptable (both LF and CRLF).
abc,def\n => ( 'abc', 'def' ) abc,def\r\n => ( 'abc', 'def' )
When building a string using csv_build, all non-numeric strings will always be enclosed in quotes.
Takes a list of fields and will generate a CSV string. This subroutine will raise an exception if any errors occur.
Parses a CSV string. Returns a list of fields it found. This subroutine will raise an exception if a string could not be properly parsed.
Thomas Peters, <email@example.com>
Copyright (C) 2013 by Thomas Peters
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.4 or, at your option, any later version of Perl 5 you may have available.
Module Install Instructions
To install Text::CSV::Easy, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Text::CSV::Easy
For more information on module installation, please visit the detailed CPAN module installation guide.