in reply to Re^2: joining string content
in thread joining string content
Maybe the core of your problem is that you have a string like this:
my $string = '+book +dog +cat';
... and you want to transform it into
"+book", "+dog", "+cat"
Then, the following code could do that:
my $string = '+book +dog +cat'; my @raw_params = split /\s+/, $string; my @quoted_params = map { qq{"$_"} } @raw_params; my $quoted_params_string = join ", ", @quoted_params; print $quoted_params_string;
Update: johngg++ spotted an error that resulted in pluses being added unnecessarily.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: joining string content
by joyfedl (Acolyte) on Jun 24, 2025 at 12:53 UTC | |
by Corion (Patriarch) on Jun 24, 2025 at 13:10 UTC | |
by joyfedl (Acolyte) on Jun 24, 2025 at 13:23 UTC | |
by tybalt89 (Monsignor) on Jun 24, 2025 at 15:09 UTC | |
by joyfedl (Acolyte) on Jun 24, 2025 at 15:14 UTC |