H
hudson
Here's my idea for a wordwrap function:
Usage:
use lib "./";
use Modules::AddNewLines;
$output = add_new_lines($output);
Module:
---------------------------------------
package Modules::AddNewLines;
use strict;
use vars qw(@ISA @EXPORT $VERSION);
use Exporter;
$VERSION = 1.00; # Or higher
@ISA = qw(Exporter);
@EXPORT = qw(add_new_lines);
sub add_new_lines {
my $string = shift;
my $count = 1;
my $new_string;
while ($string =~ /(.)/g) {
$new_string .= $1;
if ($count >= 80 && $1 eq " ") {
$new_string .= "\n";
$count = 0;
}
$count++;
}
return $new_string;
}
1;
Usage:
use lib "./";
use Modules::AddNewLines;
$output = add_new_lines($output);
Module:
---------------------------------------
package Modules::AddNewLines;
use strict;
use vars qw(@ISA @EXPORT $VERSION);
use Exporter;
$VERSION = 1.00; # Or higher
@ISA = qw(Exporter);
@EXPORT = qw(add_new_lines);
sub add_new_lines {
my $string = shift;
my $count = 1;
my $new_string;
while ($string =~ /(.)/g) {
$new_string .= $1;
if ($count >= 80 && $1 eq " ") {
$new_string .= "\n";
$count = 0;
}
$count++;
}
return $new_string;
}
1;