in reply to Text::Wrap not working

That's because you didn't pass anything to the wrap function:
use strict; use warnings; use Text::Wrap qw(wrap $columns $huge); $columns = 40; $huge = 'wrap'; my $text = 'break up this really long sentence for me please'; print wrap('', '', $text); __END__ break up this really long sentence for me please

See more EXAMPLES.

Replies are listed 'Best First'.
Re^2: Text::Wrap not working
by matua105 (Novice) on Aug 23, 2010 at 20:40 UTC
    Thanks toolic. I used Example 3 but it is still not working. I am thinking it has to do with the rest of the code.

    use Text::Wrap; $text = $message; @lines = split(/\n/, $text); $lCnt .= $#lines+1; $lineStart = 80; $lineHeight = 24; $Text::Wrap::columns = 35; print wrap('','',@text);
      Your new code doesn't work because you never assigned any values to your @text array. This error would have been caught if you use strict and warnings. I wonder if you really meant:
      print wrap('','',@lines);

      Did the code in my original reply work for you?

        Hi toolic:

        Your original example did not work for me. Many of the variables are being passed via html user input. Thus message is:

        $message = $q->param('message');

        Message is obtained from a textarea box that is embedded on an image and is sent via sendmail in the cgi. The problem is the text is not wrapping in the image box.