File I/O Manipulation....

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
 
I

Ian Wilson

<Additional newsgroup removed>
Thank you all for your replies. I appreciate the time you have spent on
my problem.

Suppose I use the following solution:

<snip: repeat of earlier post with different subject & thread>

Since you appear to be using Google groups, you may be unaware that most
readers of the comp.lang.perl.misc newsgroup do not use google groups
and that therefore it is helpful to follow long established conventions
that predate the existence of Google.

See http://groups.google.com/googlegroups/posting_style.html

in particular:
http://groups.google.com/googlegroups/posting_style.html#summarize

Since you posted a new posting rather than replying to an existing one,
your posting is detached from the related thread. Since you didn't quote
any context, many people will have a hard time working out what you are
talking about.

I can't remember if you've been pointed to
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
but its well worth reading too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top