I need to parse tab/space delimited files that have a lot of columns in Perl. The values are such that the there are large strings enclosed within double quotes. These strings can have any characters such as tabs and spaces or anything else.
When I try to parse them with the split function it splits these strings as well. Now how can I make perl understand that the strings within the " " are a single column entry?
A simple example is,
12 345546.67677 "Hello World!!!" -567.55656 0.5465767 "Hello_Again; "
Use the Text::CSV
library, which handles all the edge cases for you. It lets you set the delimiter:
my $csv = Text::CSV->new({sep_char => "\t"});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With