http://qs321.pair.com?node_id=1070469

freddo411 has asked for the wisdom of the Perl Monks concerning the following question:

I may have found a bug in Text::Wrap. I wrote a test to illuminate the situation (see below). Can anyone confirm that this is a problem in their environment? I haven't worked out the fix yet...
Test Script:
use Text::Wrap; local $| = 1; print "Text::Wrap info: \n"; print "Subverion: $Text::Wrap::SUBVERSION \n"; print "Version: $Text::Wrap::VERSION \n"; my @tests = ( 'the quick brown fox jumped over the lazy dog', '==============================================', ); my $columns = 28; local $Text::Wrap::columns = $columns; local $Text::Wrap::unexpand = 0; local $Text::Wrap::huge = 'wrap'; foreach my $str ( @tests ) { my $wrapped = wrap('', '', $str); chomp($wrapped); print "\n"; print "123456789|123456789|123456789|123456789|123456789|123456789|\ +n\n"; print $wrapped; print "\n-----------\n\n"; }
Results:
Text::Wrap info: Subverion: modern Version: 2012.0818 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- This shouldn't happen at /usr/local/lib/perl5/5.18.0/Text/Wrap.pm line + 92.

-------------------------------------
Fred

Replies are listed 'Best First'.
Re: Possible bug in Text::Wrap ???
by toolic (Bishop) on Jan 13, 2014 at 21:43 UTC
    I get a different (expected?) output on perl v5.14.2:
    Text::Wrap info: Subverion: Version: 2009.0305 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- 123456789|123456789|123456789|123456789|123456789|123456789| =========================== =================== -----------

    UPDATE: perl5180delta mentions an update to Text::Wrap.

Re: Possible bug in Text::Wrap ???
by jethro (Monsignor) on Jan 13, 2014 at 21:52 UTC
    I get the same buggy output, perl v5.18.1, same Text::Wrap version
Re: Possible bug in Text::Wrap ???
by rnewsham (Curate) on Jan 13, 2014 at 21:44 UTC

    I get this on perl v5.16.3

    Text::Wrap info: Subverion: Version: 2009.0305 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- 123456789|123456789|123456789|123456789|123456789|123456789| =========================== =================== -----------
Re: Possible bug in Text::Wrap ???
by VinsWorldcom (Prior) on Jan 14, 2014 at 00:16 UTC

    Works fine on Windows 7 x64 with Strawberry Perl 5.18.1.

    VinsWorldcom@C:\Users\VinsWorldcom\tmp> test.pl Text::Wrap info: Subverion: modern Version: 2013.0523 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- 123456789|123456789|123456789|123456789|123456789|123456789| =========================== =================== -----------
Re: Possible bug in Text::Wrap ???
by kevbot (Vicar) on Jan 14, 2014 at 05:52 UTC
    Mac OS X, 10.9.1 Perl v5.16.2 (system perl)
    Text::Wrap info: Subverion: Version: 2009.0305 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- 123456789|123456789|123456789|123456789|123456789|123456789| =========================== =================== -----------
    Mac OS X, 10.9.1 Perl v5.18.1 (perlbrew)
    Text::Wrap info: Subverion: modern Version: 2012.0818 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- This shouldn't happen at /Users/kevbot/perl5/perlbrew/perls/perl-5.18. +1-threads/lib/5.18.1/Text/Wrap.pm line 84.
      I just updated Text::Wrap using cpanm, and now it works for my local perlbrew install of v5.18.1

      Mac OS X, 10.9.1 Perl v5.18.1 (perlbrew)

      Text::Wrap info: Subverion: modern Version: 2013.0523 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- 123456789|123456789|123456789|123456789|123456789|123456789| =========================== =================== -----------
        I was able to replicate this fix.

        Summary:

        * Text::Wrap version 2012.0818 contained a bug.

        * Text::Wrap version 2013.0523 includes a fix.

        -------------------------------------
        Nothing is too wonderful to be true
        -- Michael Faraday

Re: Possible bug in Text::Wrap ???
by hdb (Monsignor) on Jan 14, 2014 at 10:03 UTC

    I did get the same error but updating Text::Wrap solved it:

    c:> cpan install Text::Wrap
Re: Possible bug in Text::Wrap ???
by Discipulus (Canon) on Jan 14, 2014 at 08:03 UTC
    Hello, i got the error with Perl 5.16.2 MSWin32-x64-multi-thread,'Text::Wrap', 2012.0818. Other 2 distros seems ok


    c:\SCRIPTS>c:\ulisse\strawberry\perl\bin\perl.exe -MConfig -MText::Wra +p -e "print qq(Perl $Config{version} $Config{archn ame },'Text::Wrap', $Text::Wrap::VERSION) " & c:\ulisse\strawberry\pe +rl\bin\perl.exe C:\scripts\textWrapPM01.pl Perl 5.14.2 MSWin32-x86-multi-thread,'Text::Wrap', 2009.0305Text::Wrap + info: Subverion: Version: 2009.0305 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- 123456789|123456789|123456789|123456789|123456789|123456789| =========================== =================== ----------- c:\SCRIPTS> c:\SCRIPTS> c:\SCRIPTS> c:\SCRIPTS> c:\SCRIPTS> c:\SCRIPTS>c:\ulisse\straw64\perl\bin\perl.exe -MConfig -MText::Wrap - +e "print qq(Perl $Config{version} $Config{archname },'Text::Wrap', $Text::Wrap::VERSION) " & c:\ulisse\straw64\perl\bin +\perl.exe C:\scripts\textWrapPM01.pl Perl 5.16.2 MSWin32-x64-multi-thread,'Text::Wrap', 2012.0818Text::Wrap + info: Subverion: modern Version: 2012.0818 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- This shouldn't happen at c:/ulisse/straw64/perl/vendor/lib/Text/Wrap.p +m line 84. c:\SCRIPTS> c:\SCRIPTS> c:\SCRIPTS> c:\SCRIPTS> c:\SCRIPTS>c:\perl\bin\perl.exe -MConfig -MText::Wrap -e "print qq(Per +l $Config{version} $Config{archname },'Text::Wrap ', $Text::Wrap::VERSION) " & c:\perl\bin\perl.exe C:\scripts\textWrapP +M01.pl Perl 5.8.8 MSWin32-x86-multi-thread,'Text::Wrap', 2005.082401Text::Wra +p info: Subverion: Version: 2005.082401 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- 123456789|123456789|123456789|123456789|123456789|123456789| =========================== =================== ----------- c:\SCRIPTS>
    HTH
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: Possible bug in Text::Wrap ???
by Bloodnok (Vicar) on Jan 15, 2014 at 11:26 UTC
    FWIW ...
    $ uname -a ; perl -v ; perl t.pl Linux dpointo8-ThinkPad-T400 3.2.0-58-generic-pae #88-Ubuntu SMP Tue D +ec 3 18:00:02 UTC 2013 i686 i686 i386 GNU/Linux This is perl 5, version 14, subversion 2 (v5.14.2) built for i686-linu +x-gnu-thread-multi-64int (with 56 registered patches, see perl -V for more detail) Copyright 1987-2011, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. Text::Wrap info: Subverion: Version: 2009.0305 123456789|123456789|123456789|123456789|123456789|123456789| the quick brown fox jumped over the lazy dog ----------- 123456789|123456789|123456789|123456789|123456789|123456789| =========================== =================== -----------
    A user level that continues to overstate my experience :-))
      This problem persists in v5.18.4 I'm hoping to find a solution because it's breaking one of our services. :/
        Sorry, I thought I was logged in. It was me that reported this is still broken in perl v5.18.4