Please note that you say the tab / space is limited. If the delimiters are mixed and / or you need to treat consecutive spaces as one, using Text :: ParseWords might be easier:
#!/usr/bin/perl use Text::ParseWords qw( quotewords ); use YAML; while ( my $line = <DATA> ) { print Dump [ quotewords('\s+', 0, $line) ]; } __DATA__ 12 345546.67677 "Hello World!!!" -567.55656 0.5465767 "Hello_Again; "
Output:
---
- 12
- 345546.67677
- Hello World !!!
- -567.55656
- 0.5465767
- 'Hello_Again; ''
source share