#!/usr/bin/env perl #use strict; my @theSections = ("000toc_comments", "001abstract_jodi", "002empty_mmm", "003code1_gnu", "004code2_empty", "005zines_project3", "006diy_project2", "007craphound_project1", "008dissent1_function", "009dissent2_matter", "010tmpSlave_empty"); foreach $sumSection (@theSections) { #change this variable to change the text $textForPrinting = $sumSection; $psName = $sumSection; #first we parse $linesInTxt = &parseText($textForPrinting . ".groff"); print $linesInTxt; #then we jump &makePS($textForPrinting); my $jumped = $textForPrinting . "Jump.groff"; #$toPrint = "groff $jumped | lpr"; #$toPrint = "groff $jumped >| $textForPrinting.ps"; system $toPrint; } sub makePS { my $nonJump = @_[0]; my $numberOfLines = $linesInTxt + 1; my $numberOfLinesTek = $linesInTxt; my $counter = 0; #this is the file that we will build my $xtraa = $nonJump . "Jump.groff"; open TYPESET, "> $xtraa"; #change the approach. there will be one jump per line. foreach (0..$numberOfLinesTek) { $thisIsLine = "lineNumber" . $_; $itSizeIs = @$thisIsLine; $theJumps[$_] = int(rand($itSizeIs)); print "$thisIsLine\nsize $itSizeIs\njump $theJumps[$_]\n\n"; } #first, insert header and two lines of empty commenting open HEADER, "< headerJumPrin.txt"; while (
) { print TYPESET $_; } #print TYPESET "\\\"\n\\\"\n"; foreach $aLine (0..$numberOfLinesTek) { $thisName = "lineNumber" . $aLine; $lineSize = @$thisName - 1; print "$lineSize\n"; if (@$thisName[0] ne ".") { print "slap"; foreach $thisLetter (0..$lineSize) { $randomJump = int(rand(20)); $hereNow = "\\h'" . $randomJump . "M'@$thisName[$thisLetter]\\h'-" . $randomJump . "M'"; print TYPESET $hereNow; } } else { print "nonslap"; foreach $thisLetter (0..$lineSize) { $randomJump = int(rand(30)); $hereNow = @$thisName[$thisLetter]; print TYPESET $hereNow; } } print TYPESET "\n"; } } #this function produces an array of letters per line in text file. #the names of these arrays are lineNumber0, lineNumber1, lineNumber2, etc. sub parseText { my $currentLine; my @currentLineLetters; my $TEXTlines = 0; my $wclTEXT = $TEXTlines - 1; my $wcmTEXT = 0; open TEXT, "< $_[0]"; # parse text while () { chomp; @currentLineLetters = split //, $_; $currentLine = "lineNumber" . $TEXTlines; #how to make this run under strict? #its basically to have an array of letters per line. @$currentLine = @currentLineLetters; $wclTEXT = $TEXTlines; ++$TEXTlines; #how to return more than one scalar? how to return one or more arrays? } # get some data --$TEXTlines; foreach (0..$TEXTlines) { $currentLine = "lineNumber" . $_; $wcmTEXT += @$currentLine; } $TEXTlines; }