Rob Dixon wrote:
Gunnar Hjalmarsson wrote:
[EMAIL PROTECTED] wrote:
On Jan 14, 5:08 pm, [EMAIL PROTECTED] (Gunnar Hjalmarsson) wrote:
open my $IN, '<', 'infile.txt' or die $!;
open my $OUT, '>', 'outfile.txt' or die $!
while ( <$IN> ) {
print $OUT scalar <$IN> if /^findable/;
}
OK here's what I've got:
<code that copies the whole file snipped>
This (obviously) copies the whole text file. How can I select only
certain lines to copy based on either the line above or below it?
I suggested a solution. Why do you ignore my suggestion and repeat
your question?
Your suggestion didn't tell him how to solve his problem Gunnar.
Of course it did (and still does).
C:\home>type test.pl
while ( <DATA> ) {
print scalar <DATA> if /^findable/;
}
__DATA__
junk
junk
findable text with a regexp
information I care about
more findable text
junk
junk
findable text with a regexp
more information I care about
more findable text
junk
junk
C:\home>test.pl
information I care about
more information I care about
C:\home>
A construct like the program below may help.
<another solution snipped>
Sure, that would work too.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/