Ok, here's two pieces of code that i'm trying to use.

This one is to try to center the headings and print the page numbers
#!/usr/bin/perl use strict; use warnings; my $file = '/u/home/jhart2/perl/project3Data.txt'; # Name the fil +e open(INFO, $file); # Open the file for input my @Project3 = <INFO>; # Read it into an array my $NoOfCharsPerLine = 80; my $NoOfLinesPerPage = 100; my $RightMargin = 7; my $header = 3; my $footer = 5; my $width = 80; my $heading; print "Page: $pageNum\n"; #while (Project3) { if (/(SECTION)(\s)(\d+)(.*)(\3)(\.1\.)(.*)/) { $heading = "$1.$2.$3.$4"; format Ident = @||||||||||||||||||||||||||||||||||||||||||||||||||||| +|| "$heading" . } }

This is what it returns:
[evans:19:55:07 perl]$ ./project3-6.pl Global symbol "$pageNum" requires explicit package name at ./project3- +6.pl line 25. Missing right curly or square bracket at ./project3-6.pl line 40, at e +nd of line syntax error at ./project3-6.pl line 40, at EOF Execution of ./project3-6.pl aborted due to compilation errors.
I know that I need to define the $pageNum but I don't know what to define it as. And I can't figure out the other errors. I am VERY NEW to perl, and to unix for that matter.

This is the other code I used to try to center the headings:
#!/usr/bin/perl use strict; use warnings; my $file = '/u/home/jhart2/perl/project3Data.txt'; # Name the fil +e open(INFO, $file); # Open the file for input my @Project3 = <INFO>; # Read it into an array my $NoOfCharsPerLine = 80; my $NoOfLinesPerPage = 100; my $RightMargin = 7; my $header = 3; my $footer = 5; my $width = 80; my $heading; for (@Project3) { if (/(SECTION)(\s)(\d+)(.*)(\3)(\.1\.)(.*)/) { $heading = $1.$2.$3.$4; print " " x (($width-length($heading))/2); } }


It doesn't print anyting.

In reply to Re^2: Formatting Text...Again by Anonymous Monk
in thread Formatting Text...Again 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.