G
greggiefen
Hello,
I am new to Perl but have programmed in other languages in school. I
am trying to parse a VERY large text file. I initially tried to load
it all into an array but that seemed to fail due to memory constraints.
This is what i'm trying to do:#!/usr/bin/perl -w
open(OF, "output.txt");
while ($line = <OF>) {
#If a line contains this i wanted it printed so the date will be
included
if($line =~ /Page 1/) {
print $line;
}
#I want all the records regarding Mr. Smith printed. However the
records span multiple lines
if($line =~ /Mr Smith/) {
print $line;
#the lines of the peronsal records end in a line of all asterix
while ($line =~ /[^\*]/) {
print $line;
#do something magical here
}
}
}
What I need to do is to somehow get the perl script to jump to the next
line after printing the current line in the last loop, but still stay
in the loop until it reached the line of all **. If i could get all of
it into an array i could simply incriment the index until i reched the
line of all asterixs.
I am new to Perl but have programmed in other languages in school. I
am trying to parse a VERY large text file. I initially tried to load
it all into an array but that seemed to fail due to memory constraints.
This is what i'm trying to do:#!/usr/bin/perl -w
open(OF, "output.txt");
while ($line = <OF>) {
#If a line contains this i wanted it printed so the date will be
included
if($line =~ /Page 1/) {
print $line;
}
#I want all the records regarding Mr. Smith printed. However the
records span multiple lines
if($line =~ /Mr Smith/) {
print $line;
#the lines of the peronsal records end in a line of all asterix
while ($line =~ /[^\*]/) {
print $line;
#do something magical here
}
}
}
What I need to do is to somehow get the perl script to jump to the next
line after printing the current line in the last loop, but still stay
in the loop until it reached the line of all **. If i could get all of
it into an array i could simply incriment the index until i reched the
line of all asterixs.