Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Split Malfunction

by toolic (Bishop)
on Oct 23, 2015 at 13:51 UTC ( [id://1145760]=note: print w/replies, xml ) Need Help??


in reply to Split Malfunction

If you want to preserve whitespace inside double quotes, you can use Text::CSV instead of split:
use warnings; use strict; use Text::CSV; use Data::Dumper; my $str = q(xxxxx "alpha 2" xxx xxxxx "name " xxx xxx xxxx xxx); my $csv = Text::CSV->new( { binary => 1, sep_char => ' '} ) # should +set binary attribute. or die "Cannot use CSV: ".Text::CSV->error_diag (); my $status = $csv->parse($str); # parse a CSV string into fiel +ds my @columns = $csv->fields(); # get the parsed fields print Dumper(\@columns); __END__ $VAR1 = [ 'xxxxx', 'alpha 2', 'xxx', 'xxxxx', 'name ', 'xxx', 'xxx', 'xxxx', 'xxx' ];

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-24 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found