KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a lot of text files with fixed-width fields: <c> <c> <c> Dave Thomas 123 Main Dan Anderson 456 Center Wilma Rainbow 789 Street The rest of the files are in a similar format, where the <c> will mark the beginning of a column, but they have various (unknown) column & space widths. What's the best way to parse these files? I tried using Text::CSV , but since there's no delimiter it's hard to get a consistent result (unless I'm using the module wrong): my $csv = Text::CSV->new(); $csv->sep_char (' '); while (<FILE>){ if ($csv->parse($_)) { my @columns=$csv->fields(); print $columns[1] . "\n"; } }
Tags (comma-separated)
Save Edits
Cancel