R
RodFGWA
Thank you all for your replies. I appreciate the time you have spent on
my problem.
Suppose I use the following solution:
#!/usr/bin/perl
use warnings;
use strict;
open FILE, '<', 'text_file' or die "Cannot open 'text_file' $!";
chomp( @ARGV = <FILE> );
close FILE;
open OUT, '>>', 'OUTPUT_FILE' or die "Cannot open 'OUTPUT_FILE' $!";
my $lines = 10;
while ( <> ) {
$. == 1 && print OUT "*****\n";
$. <= $lines && print OUT $_;
$. > $lines || eof and close ARGV;
}
__END__
I chose this one because it seems the likely candidate to extend for
what I would ideally like to do. However, Perl is so obscure to me now
that I may be wrong about that.
I would like to print the lines of each file that begin with an open
parenthesis '('. These are the comment lines in the beginning of each
file.
I originally chose the top ten lines because I thought that would
suffice, but upon reflection, I need only the lines that begin with
'('. Sometimes there are more than 10 comment lines.
Once the comment lines have stopped there are additional lines, but I
do not care about these, so I can go on to the next file.
Ideally, I would like to print the lines that begin with certain
headers beginning with a '(', such as '(CUSTOMER', or '(MATERIAL'.
So, read each line
Does it begin with '(' OR Does it begin with '(CUSTOMER'
If it Does Print the line to the Output File
my problem.
Suppose I use the following solution:
#!/usr/bin/perl
use warnings;
use strict;
open FILE, '<', 'text_file' or die "Cannot open 'text_file' $!";
chomp( @ARGV = <FILE> );
close FILE;
open OUT, '>>', 'OUTPUT_FILE' or die "Cannot open 'OUTPUT_FILE' $!";
my $lines = 10;
while ( <> ) {
$. == 1 && print OUT "*****\n";
$. <= $lines && print OUT $_;
$. > $lines || eof and close ARGV;
}
__END__
I chose this one because it seems the likely candidate to extend for
what I would ideally like to do. However, Perl is so obscure to me now
that I may be wrong about that.
I would like to print the lines of each file that begin with an open
parenthesis '('. These are the comment lines in the beginning of each
file.
I originally chose the top ten lines because I thought that would
suffice, but upon reflection, I need only the lines that begin with
'('. Sometimes there are more than 10 comment lines.
Once the comment lines have stopped there are additional lines, but I
do not care about these, so I can go on to the next file.
Ideally, I would like to print the lines that begin with certain
headers beginning with a '(', such as '(CUSTOMER', or '(MATERIAL'.
So, read each line
Does it begin with '(' OR Does it begin with '(CUSTOMER'
If it Does Print the line to the Output File