Subject: | Text::Hyphen documentation bug |
Date: | Thu, 13 Aug 2015 20:56:52 +0200 |
To: | bug-Text-Hyphen [...] rt.cpan.org |
From: | Laurent Rosenfeld <laurent.rosenfeld [...] googlemail.com> |
Hi,
I have just tried the example of Text::Hyphen you give in your
documentation (
http://search.cpan.org/~kappa/Text-Hyphen-0.11/lib/Text/Hyphen.pm), and it
did not work properly:
$ perl -e 'use Text::Hyphen;
my $hyphenator = new Text::Hyphen;
print $hyphenator->hyphenate('representation');
'
representation
I ran your example under the debugger and found that this code line:
return wantarray ? @pieces : join($delim, @pieces);
does not work properly with print in the calling program, because print
forces a list context, so that your module return the @pieces array, not
the joined string, and the pieces are glued together by the print.
Running it again with a scalar context solved the issue:
$ perl -e 'use Text::Hyphen;
my $hyphenator = new Text::Hyphen;
print scalar $hyphenator->hyphenate('representation');
'
rep-re-sen-ta-tion
So, only a minor glitch in the documentation, I think.
Best regards,
Laurent.