#!/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" . } }
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.[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.
#!/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); } }
In reply to Re^2: Formatting Text...Again
by Anonymous Monk
in thread Formatting Text...Again
by lollipop7081
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |