I am VERY new to perl, I'm in a undergrad Software Tools class and my professor assigned perl just to see how good we'd do (with only basic instruction on perl).

I DO NOT WANT SOMEONE TO DO MY HOMEOWRK FOR ME!!!

The assignment is that I need to format a text file where each section can be treated as a chapter and the headings should be centered.
He wants a table of contents.
Also, each section should be broken up into seperate pages and each page numbered with roman numerals that match the table of contents.
And finally, he wants an Index whose keywords are any word that appears in the question and the answer and doesn't appear more than 10 times.

Here's a part of the text he provided:
SECTION 35 - BUILDING VIM FROM SOURCE 35.1. How do I build Vim from the sources on a Unix system? For a Unix system, follow these steps to build Vim from the sources: - Download the source and run-time filles archive (vim-##.tar.bz2) fro +m the ftp://ftp.vim.org/pub/vim/unix directory. - Extract the archive using the bzip2 and tar utilities using the com +mand: $ bunzip2 -c <filename> | tar -xf - - Run the 'make' command to configure and build Vim with the default configuration. - Run 'make install' command to installl Vim in the default directory. To enable/disable various Vim features, before running the 'make' comm +and you can run the 'configure' command with different flags to include/ex +clude the various Vim features. To list all the available options for the 'configure' command, use: $ configure -help
He wants to make sure that the characters per line and lines per page can be set in the script. So to do that I've done the following:
#!/usr/bin/perl # # Reformat the project3Dada.txt file to make more accesible $file = '/u/home/jhart2/perl/project3Data.txt'; # Name the fil +e open(INFO, $file); # Open the file for input use strict; use warnings; my $NoOfCharsPerLine = 80; my $NoOfLinesPerPage = 100; my $RightMargin = 7; my $header = 3; my $footer = 5; my @argument; # Read command line arguments @argument = split(/=/, $ARGV[0]); if ($argument[1] =~ /\D/) { print "Nonumeric value for lines option \"$argument[1]\" --scr +ipt aborted\n"; } if ($argument[0] eq "--chars") { $NoOfCharsPerLine = $argument[1]; } elsif ($argument[0] eq "--lines") { $NoOfLinesPerPage = $argument[1]; } else { print "unrecognized command line option \"$argument[0]\" --scr +ipt aborted\n"; exit; } close(INFO); # Close the file print "$NoOfCharsPerLine\n"; print "$NoOfLinesPerPage\n";
So, because I'm so new I'm thinking that maybe I just don't know what to look for. I've used my text book, google, and forums like this one but i'm still at a loss.

All I need is for someone to point me in the right direction to get farther than testing the chars/line and the lines/page.

Thanks so much!

Edited by planetscape - added readmore tags

( keep:2 edit:11 reap:0 )


In reply to Formatting Text by lollipop7081

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.