in reply to Re^2: Text::Wrap not working
in thread Text::Wrap not working

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?

Replies are listed 'Best First'.
Re^4: Text::Wrap not working
by matua105 (Novice) on Aug 23, 2010 at 21:18 UTC
    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.

      GD::Text::Wrap is frequently used with CGI. Maybe you should try it. For example:
      #!/usr/bin/perl use strict; use warnings; use GD; use GD::Text::Wrap; my $gd = GD::Image->new(800,600); my $text = <<EOSTR; This is the way it is. This is the way it was. EOSTR my $wrapbox = GD::Text::Wrap->new( $gd, text => $text); $wrapbox->set_font(gdMediumBoldFont); $wrapbox->set_font('arial', 12); $wrapbox->set(align => 'left', width => 40); $wrapbox->draw(10, 140); print "\n$text\n";