Hi all,
I am trying to take a text field of up to 360 characters and split it into an array of strings that are maximum 60 characters.
here is my code...
It is a test script so i can get it right on the split.
I think this is right, but it does not seem to work, can anyone see where i am going wrong.
Thanks
Jez
I am trying to take a text field of up to 360 characters and split it into an array of strings that are maximum 60 characters.
here is my code...
Code:
#!/perl/bin/perl -w
my $longText = <<END;
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed quam. Maecenas non pede. Donec metus tortor, cursus quis, aliquet et, ornare id, pede. Vestibulum vestibulum porttitor nisi. Quisque tristique vehicula lacus. Donec id dui. Donec nec massa nec turpis aliquet ornare. Integer vitae ante. Suspendisse potenti. Sed enim est, dignissim a, fermentum sed.
END
$count = length($longText);
@stringChunksArray = split(/.{60}/, $longText);
print STDOUT $count ." is the total characters in the long text";
for($i=0;$i<@stringChunksArray;$i++){
print STDOUT $stringChunksArray[$i]."\n";
print STDOUT length($stringChunksArray[$i]) . "\n\n\n";
}
exit(0);
It is a test script so i can get it right on the split.
I think this is right, but it does not seem to work, can anyone see where i am going wrong.
Thanks
Jez