File: demo_cruciform.pl

package info (click to toggle)
libperl6-form-perl 0.090-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 584 kB
  • sloc: perl: 3,080; makefile: 8
file content (49 lines) | stat: -rwxr-xr-x 1,364 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use 5.010;
use warnings;

use Perl6::Form;

my $proscribed = join '|', map quotemeta,
	qw(villain plot libel treacherous murderer false deadly 'G');

sub break_and_censor {
	my ($breaker) = @_;
	return sub {
		my ($str,$rem,$ws) = @_;
		my ($nextline, $more) = $breaker->(@_);
		$nextline =~ s/($proscribed)/'X' x length $1/egi;
		return ($nextline, $more);
	}
}

sub censored() {
	return { field => [ qr/[{] (X+) [}]/x => sub {
							my ($match, $opts) = @_;
							$opts->{break} = break_and_censor($opts->{break});
							return '{[[{' . length($match->[1]) . '}[[}';
						}
			          ]
	       };
}

my $script = do{local$/;<DATA>};

print form censored,
	 "[Ye following tranfcript hath been cenfored by Order of ye King]\n\n",
	 "        {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}",
	           $script;

__DATA__
And therefore, since I cannot prove a lover,
To entertain these fair well-spoken days,
I am determined to prove a villain
And hate the idle pleasures of these days.
Plots have I laid, inductions dangerous,
By drunken prophecies, libels and dreams,
To set my brother Clarence and the king
In deadly hate the one against the other:
And if King Edward be as true and just
As I am subtle, false and treacherous,
This day should Clarence closely be mew'd up,
About a prophecy, which says that 'G'
Of Edward's heirs the murderer shall be.