P
poopdeville
Hello,
I'm working on a project, and I'm having a little bit of trouble.
Basically, what I'm trying to do is take some text as input, split
along groups of newlines (so that multiple newlines in a row have the
same effect as a single one), and make each of the elements of the new
array an HTML paragraph. Here is the relevant subroutine:
#!/usr/bin/perl -w
#use strict;
#sub paragrapher {
# my @paragraphs = split /\n+/, $_[0];
# my $new;
# for (@paragraphs) {
# if (length($_)) {
# $new = $new . "<p>$_<\/p>";
# }
# }
# return $new;
#}
If we feed the subroutine the text:
This is the super dooper intro.
OMG, this is more of a test than an intro, but whatever.
stored in a variable, the output is
<p>This is the super dooper intro.</p><p>
</p><p>
OMG, this is more of a test than an intro, but whatever.</p>
Note the totally unnecessary <p></p>. Does anyone see what could be
going wrong?
Thanks,
'cid 'ooh
I'm working on a project, and I'm having a little bit of trouble.
Basically, what I'm trying to do is take some text as input, split
along groups of newlines (so that multiple newlines in a row have the
same effect as a single one), and make each of the elements of the new
array an HTML paragraph. Here is the relevant subroutine:
#!/usr/bin/perl -w
#use strict;
#sub paragrapher {
# my @paragraphs = split /\n+/, $_[0];
# my $new;
# for (@paragraphs) {
# if (length($_)) {
# $new = $new . "<p>$_<\/p>";
# }
# }
# return $new;
#}
If we feed the subroutine the text:
This is the super dooper intro.
OMG, this is more of a test than an intro, but whatever.
stored in a variable, the output is
<p>This is the super dooper intro.</p><p>
</p><p>
OMG, this is more of a test than an intro, but whatever.</p>
Note the totally unnecessary <p></p>. Does anyone see what could be
going wrong?
Thanks,
'cid 'ooh