Le 31 juil. 09 à 15:52, Joel E. Denny a écrit :

Hi Joel,

+        # Format within margin.
+        my $new_wrapped;
+        my $text_margin = $margin - length($prefix);
+        while (length($new))
+          {
+            if (($new =~ s/^(.{1,$text_margin})(?: |$)//)
+                || ($new =~ s/^([\S]+)(?: |$)//))
+              {
+                my $line = $1;
+                $new_wrapped .= $new_wrapped ? "\n" : $leading;
+                $new_wrapped .= "$prefix$line";
+              }
+            else
+              {
+ # Should be unreachable, but we don't want an infinite
+                # loop if it can be reached.
+                die;
+              }
+          }

You might want to have a look at Text::Wrap.

Reply via email to