line2options
Replaces newlines
(any combination of "\r" and "\n" in the body text)
with commas.
It also takes care of removing any leading and trailing whitespace from
all entries.
Also see the options2line filter.
Example
[filter line2options]
One
Two
Three
[/filter]
|
Results in:
Source code
sub {
my ($value, $tag, $delim) = @_;
return $value unless length $value;
$value =~ s/\s+$//;
$value =~ s/^\s+//;
my @opts = split /[\r\n]+/, $value;
for(@opts) {
s/^\s+//;
s/[,\s]+$//;
s/,/,/g;
}
return join ",", @opts;
}
|