Two-years-after revision. New `vertical' version.
[p_s.git] / h.pl
blobf02f759352ff301b69fd87565f9b83cfc28ca1c8
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
5 # code as grid. only the grid saves!
6 # there may already be a little groff markup in this file
7 my $textFile = "sections_7,_9" unless $ARGV[0];
8 $textFile = $ARGV[0] unless not $ARGV[0];
10 # this returns the text as an array of arrays, alllinesAllleters ;)
11 my @textAoA = &parseText($textFile);
12 &horizontalMotionMarkUp(\@textAoA, 20);
14 # takes as an argument the file to be parsed, so &parseText("file")
15 sub parseText {
16 my @alllinesAllletters;
17 my @currentLineLetters;
18 open(TEXT, "<", $_[0]) || die "can't open $_[0] : $!";
20 while (<TEXT>) {
21 chomp;
22 @currentLineLetters = split //, $_;
23 push @alllinesAllletters, [@currentLineLetters];
25 @alllinesAllletters;
28 sub horizontalMotionMarkUp {
29 my @textLetters = @{$_[0]};
30 my $localMotionRange = $_[1];
31 my $aLetter;
32 my $aLineRef;
33 my $anAmount;
34 my $markedUpLetter;
36 # this is the file that we will build
37 my $newFile = $textFile . "Typeset";
38 open(TYPESET, ">", $newFile) || die "can't open $newFile : $!";
40 # for evry letter...
41 foreach $aLineRef (@textLetters) {
42 if (@$aLineRef == 0) {}
43 # the script recognizes lines that begin with a `.' or a `\'
44 elsif (@$aLineRef[0] eq "." || @$aLineRef[0] eq "\\") {
45 foreach $aLetter (@{$aLineRef}) {
46 print TYPESET $aLetter;
48 } else {
49 foreach $aLetter (@{$aLineRef}) {
50 $anAmount = int(rand($localMotionRange));
51 $markedUpLetter = "\\h'" . $anAmount . "M'$aLetter\\h'-" . $anAmount . "M'";
52 print TYPESET $markedUpLetter;
55 print TYPESET "\n";