File: demo_break_width.pl

package info (click to toggle)
libperl6-form-perl 0.06-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 588 kB
  • ctags: 104
  • sloc: perl: 3,073; makefile: 8
file content (19 lines) | stat: -rwxr-xr-x 438 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sub break_width {
	my ($str_ref, $width, $ws) = @_;
	$ws ||= '(?!)';
	for ($$str_ref) {
		my $single = qr/$ws|\n|\r|(?s:.)/;
	    return ("",   0) unless /\G((?:$single){1,$width})/gc;
		(my $result = $1) =~ s/$ws|\n|\r/ /g;
		return ($result, substr($_,pos)=~/\S/)
	}
}

use Perl6::Form;

$data = "You can play no part but Pyramus;\n"
	  . "for Pyramus is a sweet-faced man;  ";

print form {break=>\&break_width}, "|{[[[[[}|", $data;