in reply to Nested grouping or capturing inside capturing
What if "data with spaces" is not necessarily the third (or nth) field?
To make your code more robust, try Text::CSV:
use Text::CSV; my $csv = Text::CSV->new( { sep_char => ' '} ); my $fh = *DATA; # Replace *DATA with your input file name while ( my $row = $csv->getline( $fh ) ) { say join '-', @$row; } __DATA__ abc def data 123 ghi jkl "data with spaces" 456 "oh dear" "more data with spaces"
|
---|
In Section
Seekers of Perl Wisdom