J
jac
Ok, so far so good goes my first *productive* PERL program ever...
This program opens a text file and prints everything except the lines
containing words "adding", "unable", and "PNL". So far it mostly works
like I want it to except that the lines of text that contain the word
"unable" wrap at column "58" to a new line. I need to omit the new line
as well as its part of the line that contains the word I don't want.
Is there a pattern-match that I can use to delete a next line?
---INPUT TEXT -----------------------------------------------------|
196315-2 CASTING,VOLUTE,8.5
2-76811 WILL-WA PTAC02 XT70
Unable to fetch part description for part 210-9--4-04120-
210-9--4-04120-
Unable to fetch part description for part 210-9--4-04120-
210-9--4-04120-
231146-76811 S.S. TAG-REF DESIG LABEL KIT
231157-76811 S.S. TAG INSTALLATION KIT
sample output -------------------------------------------------------|
185650-76811-1 LABEL GATHERING KIT, DRVN, CENT
196315-2 CASTING,VOLUTE,8.5
2-76811 WILL-WA PTAC02 XT70
210-9--4-04120-
210-9--4-04120-
231146-76811 S.S. TAG-REF DESIG LABEL KIT
231157-76811 S.S. TAG INSTALLATION KIT
-----------------------------------------------------------------------------|
In the sample output, the numbers "210-9--4-04120-" are wrapped from a
line above it that contained the word "unable"
--- code example-----------------------------------------|
open PULLIN,"$in" || die "$in does not exist: $!\n";
open PULLOUT, ">output.txt" || die "$!\n";
while (<PULLIN>) {
if (! /adding|unable|PNL/i) {
print PULLOUT;
}
}
close(PULLIN);
close(PULLOUT);
--- end code -------------------------------------------------|
Thanks,
Alex
This program opens a text file and prints everything except the lines
containing words "adding", "unable", and "PNL". So far it mostly works
like I want it to except that the lines of text that contain the word
"unable" wrap at column "58" to a new line. I need to omit the new line
as well as its part of the line that contains the word I don't want.
Is there a pattern-match that I can use to delete a next line?
---INPUT TEXT -----------------------------------------------------|
196315-2 CASTING,VOLUTE,8.5
2-76811 WILL-WA PTAC02 XT70
Unable to fetch part description for part 210-9--4-04120-
210-9--4-04120-
Unable to fetch part description for part 210-9--4-04120-
210-9--4-04120-
231146-76811 S.S. TAG-REF DESIG LABEL KIT
231157-76811 S.S. TAG INSTALLATION KIT
sample output -------------------------------------------------------|
185650-76811-1 LABEL GATHERING KIT, DRVN, CENT
196315-2 CASTING,VOLUTE,8.5
2-76811 WILL-WA PTAC02 XT70
210-9--4-04120-
210-9--4-04120-
231146-76811 S.S. TAG-REF DESIG LABEL KIT
231157-76811 S.S. TAG INSTALLATION KIT
-----------------------------------------------------------------------------|
In the sample output, the numbers "210-9--4-04120-" are wrapped from a
line above it that contained the word "unable"
--- code example-----------------------------------------|
open PULLIN,"$in" || die "$in does not exist: $!\n";
open PULLOUT, ">output.txt" || die "$!\n";
while (<PULLIN>) {
if (! /adding|unable|PNL/i) {
print PULLOUT;
}
}
close(PULLIN);
close(PULLOUT);
--- end code -------------------------------------------------|
Thanks,
Alex