You have confused the $string version and the file version of the data that you are editing. Probably the easiest thing to do is to use @Project like this:
#!/usr/bin/perl use strict; use warnings; my @Project = <DATA>; chomp (@Project); # chomp is a little more selective than chop! It rem +oves $/ my $width = 80; my $heading; for (@Project) { if (/(SECTION\s\d+.*)/) { print ' ' x (($width-length($1))/2); # Center the headin +g } print "$_\n"; } __DATA__ ====================================================================== +======= 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 -
Prints:
====================================================================== +======= 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 -
Note that the sample code avoids needing an external file by using __DATA__. This is a trick worth cultivating for posting questions here.
In reply to Re: Printing Help
by GrandFather
in thread Printing Help
by lollipop7081
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |