How do I convert a multiline string to array?
my $text= \" ads da
sda
s
da
d
as
das
d a as dasd
\\n
\";
Note : I dont want to re
My sense is you are focusing on the wrong problem.
Instead of trying to convert a scalar multi-line string constant into a list, maybe your question should be "How do I have a multi-line string initiated into a Perl list or array?"
Look at Perl's List value constructors in Perldata.
Of particular applicability to your question is how to use a heredoc to initiate an array with a multi-line string:
#!/usr/bin/perl
use strict; use warnings;
use YAML;
my @text= <
Prints:
---
- " ads da\n"
- "sda\n"
- "s \n"
- "da\n"
- "d\n"
- "as\n"
- "\n"
- "das\n"
- "d a as dasd\n"
- "\n"
- "\n"
- "\n"
Use the idioms Luke!