- Timestamp:
- 2004-06-03T13:09:28+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/MARCPlug.pm
r7533 r7547 66 66 #use MARC::Record; 67 67 #use MARC::Batch; 68 use Text::Wrap;69 68 70 69 sub new { … … 251 250 252 251 # line wrapping 253 $Text::Wrap::columns = 80; 254 $$textref = wrap("", "", $$textref); 255 252 $$textref = &wrap_text_in_columns($$textref, 80); 256 253 $$textref = "<pre>\n" . $$textref . "</pre>\n"; # HTML formatting... 257 254 … … 261 258 } 262 259 260 sub wrap_text_in_columns 261 { 262 my ($text, $columnwidth) = @_; 263 my $newtext = ""; 264 my $linelength = 0; 265 266 # Break the text into words, and display one at a time 267 my @words = split(/ /, $text); 268 269 foreach $word (@words) { 270 # If printing this word would exceed the column end, start a new line 271 if (($linelength + length($word)) >= $columnwidth) { 272 $newtext .= "\n"; 273 $linelength = 0; 274 } 275 276 # Write the word 277 $newtext .= " $word"; 278 if ($word =~ /\n/) { 279 $linelength = 0; 280 } else { 281 $linelength = $linelength + length(" $word"); 282 } 283 } 284 285 $newtext .= "\n"; 286 return $newtext; 287 } 263 288 264 289
Note:
See TracChangeset
for help on using the changeset viewer.