#!/usr/bin/env perl #print "page size is " .$= . "\n"; # 60 format TEST_1_TOP = Passwd File Name Name Login Office Uid Gid Home ------------------------------------------------------ . format TEST_1 = @###.# @##########.### @##.###| @.### @##.. . $num, $num, $snum, $snum, $snum 1234567 1234567.890 -12.340| -12.3 -12.. . left|@<<<<| right|@>>>>| |center|@||||| | num|@##.#| $twenty_two, $twenty_two, $twenty_two, $snum left|22 | right| 22| |center| 22 | num|-12.3| . format TEST_2_TOP = Passwd File Name Name Login Office Uid Gid Home ------------------------------------------------------ . format TEST_2 = Foo @<<<< @>>>> @<<<< @>>>>> @##.##### @# @.### @##.#. $name, $name, $login, $office, $uid, $uid, $gid, $gid, safdsdfsdfsdf sdfsdfsdfdfs bar @<<<< @>>>> @<<<< @>>>>> @|||||+ +@#####+ @<<<< $name, $name, $login, $office, $uid, $gid, $home baz ^<<<* *^<<<* ^<< @<_^_<< @||| ^#.## ^##.### $name, $name, $name, $login, $login, $home, $uid, $uid @#@# $uid,$uid . format TEST_3_TOP = Piggy Locations for @<< @#, @### $month, $day, $year Number: location toe size ------------------------------------------- . format TEST_3 = @) @<<<<<<<<<<<<<<<< @#.## $num, $location, $toe_size . format TEST_4_TOP = Piggy Locations for Sep 18, 2001 . format TEST_4 = Number: location toe size ------------------------------------------- 1) Market 3.50 2) Home 7.00 3) Eating Roast Beef 10.50 4) Having None 14.00 5) On the way home 17.50 ------------------------------------------- . format TEST_5_TOP = Piggy Locations for Sep 19, 2001 . format TEST_5 = Number: location toe size ------------------------------------------- 1) Market 1 2) Home 1 3) Eating Roast Beef 1 4) Having None 1 5) On the way home 1 ------------------------------------------- . format TEST_6 = Format that uses the hat @|| ^<< ^|| $long, $long, $long ^|||| @<<<< ^|||| ^###.## ^###.## ^###.# $long, $long, $long, $num, $num, $num Run out of chars! ^|||| ^<<<< ^|||| -- $short, $short,$short ^<<<*^<<<<*^<<<<<<<<<<<<< $long, $long, $long . format TEST_11 = @@@ @@@ $one,$one,$one,$one,$one,$one . format TEST_12 = @@@ Paul @@@ }Rubel @< @|| @#.# $var_one,$var_one,$var_one,$var_one,$var_one,$var_one, $var_two, $var_three, $var_four @<<< @<<< $var_one,$var_one . format TEST_13_TOP = ---- Top --- Page Number @<<<---- $i . format TEST_13 = @) @<<<<<<<<<<<<<<<< @#.## $num, $location, $toe_size @) @<<<<<<<<<<<<<<<< @#.## $num, $location, $toe_size @) @<<<<<<<<<<<<<<<< @#.## $num, $location, $toe_size @) @<<<<<<<<<<<<<<<< @#.## $num, $location, $toe_size @) @<<<<<<<<<<<<<<<< @#.## $num, $location, $toe_size @) @<<<<<<<<<<<<<<<< @#.## $num, $location, $toe_size @) @<<<<<<<<<<<<<<<< @#.## $num, $location, $toe_size ---- Bot --- Page Number @<<<---- $i @< $ff . format TEST_15 = @>>>>>>>>>>>>>> ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $author, $quote ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $quote . format TEST_14 = 1)Test of add @<<<< @||||| $b.$a, $c++ + $d++ 2)Test of add @<<<< @||| $a . $b, $c++ + $d++ . #this test is at the bottom as it breaks syntax highlighting on my emacs :( format TEST_7 = ~ non_blank: @<<<| $non_blank ~ blank unless $blank holds something, which it doesn't @<<< $blank ~~ repeat: ^<<. $string . #this is just broken in the rounding front, I don't think # this bug should be replicated format TEST_FORMAT = ^#.### ^##.## $num, $num . $test_num = $ARGV[0]; ## Test 1 if ($test_num == 1) { open (TEST_1, ">-"); $twenty_two = '22'; $num = 1234567.89012455; $snum = -12.34; # how do you set the number of lines per page, $= ($FORMAT_LINES_PER_PAGE) is # supposedly helpful for ($i = 0; $i < 13; $i++) { write TEST_1; } } elsif ($test_num == 2) { $name = 'Paul Rubel'; $login = 'rubel@crhc.uiuc.edu'; $office ='6/301'; $uid = 124.135791357; $gid = -13; $home = "/home/rubel"; open (TEST_2, ">-"); for ($i = 0; $i < 20; $i++) { write TEST_2; } } elsif ($test_num == 3) { open (TEST_3, ">-"); $month = "Sep"; $day = 18; $year = 2001; @locations = ("Market", "Home", "Eating Roast Beef", "Having None", "On the way home"); for ($i = 1; $i <= 5; $i++) { $num = $i; $toe_size = ($num * 3.5); $location = $locations[($i-1)]; write TEST_3; } } elsif ($test_num == 4) { open (TEST_4, ">-"); $month = "Sep"; $day = 18; $year = 2001; $old = select (TEST_4); $= = 10; for ($i = 0; $i < 10; $i++) { write TEST_4 } select($old) } elsif ($test_num == 5) { open (TEST_5, ">-"); $month = "Sep"; $day = 18; $year = 2001; $old = select (TEST_5); $= = 20; for ($i = 0; $i < 10; $i++) { write TEST_5 } select($old) } elsif ($test_num == 6) { open (TEST_6, ">-"); $num = 123.456; $long = "01234567890abcde fg h i jklmn12345678901234567890123456.789"; $short = 123.456; write TEST_6; } elsif ($test_num == 7) { open (TEST_7, ">-"); $blank = ""; $non_blank = " "; $string = "abcdefghijklmn"; write TEST_7; } elsif ($test_num == 8) { print " non_blank: |\n"; for ($i = 0; $i < 9; $i++) { print (" repeat: aaa.\n"); } for ($i = 0; $i < 2; $i++) { print " "; for ($j = 0; $j < 10; $j++) { print (" repeat: aaa.\n"); } } print " "; for ($i = 0; $i < 4; $i++) { print (" repeat: aaa.\n"); } print " repeat: ab .\n"; print "\n\n\n\n\n"; } #what about 9? We used 8 twice, this keeps the files and the numbers synched elsif ($test_num == 10) { $exp = 1.234e-14; $mid = 123.4567E23; $big = 123.4567E200; $little = 12.34e-20; $int = 12; printf ("1 %8.3G %8.2e\n", $exp, $exp); printf ("2 %11.6g %9.1E\n", $big, $big); printf ("3 %6.2G %6.1e\n", $little, $little); printf ("4 %4.0E\n", $mid);# The -n1 says don't wait for peole to join before you send out messages printf ("5 %6.1E %4.0e\n", $little,$mid); printf ("6 int %6.2g %6.1e\n", $int, $int); printf ("7 int %5.1G %5.0E\n", $int, $int); } elsif ($test_num == 11) { open (TEST_11, ">-"); $one = 1; write TEST_11; } elsif ($test_num == 12) { open (TEST_12, ">-"); $var_one = 1; $var_two = 2; $var_three = 3; $var_four = 4.3; write TEST_12; } elsif ($test_num == 13) { open (TEST_13, ">-"); $old = select (TEST_13); $= = 11; for ($i = 1; $i < 30 ; $i++) { $num = $i; $location = "Who Knows"; $toe_size = $i; $ff = "\f"; write TEST_13; } select($old) } elsif ($test_num == 14) { open (TEST_14, ">-"); $a = "Ruby"; $b = " Rocks"; $c = 111; $d = 222; $d[111] = "ones"; print ("a + b $d[111]\n"); print ($d++ . "\n"); $old = select (TEST_14); write TEST_14; select($old) } elsif ($test_num == 15) { open (TEST_15, ">-"); $author = "Robert Frost"; $quote = "Whose woods these are I think I know His house is by the village, though ... But I have promises to keep And miles to go before I sleep."; $old = select (TEST_15); write TEST_15; $author = "Bill"; $quote = "Shall I compare thee to a Summer's day and branch if the result is negative?"; write TEST_15; select($old) } elsif ($test_num =~ /x/) { print "test x -$test_num-\n"; open (TEST_FORMAT, ">-"); $num = 123.355555; write TEST_FORMAT; } elsif ($test_num =~ /y/) { print "test y -$test_num-\n"; open (TEST_7, ">-"); $= = 2; $blank = ""; $non_blank = " "; $string = "abcdefghijklmn"; write TEST_7; } else { print " Usage: format_test.pl test_number\n Where test_number is from 1 to 13\n" }