Re: Extracting a Range of Lines

2006-06-04 Thread joseph
""Mr. Shawn H. Corey"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 2006-05-06 at 10:20 +0800, joseph wrote: >> @line = () if /^DATE:/; ## set array @line to an empty list if line begin >> DATE? > > Yes, this will clear out the previous record. > >> push @line, $_; ## th

Re: Extracting a Range of Lines

2006-06-04 Thread Mr. Shawn H. Corey
On Mon, 2006-05-06 at 10:20 +0800, joseph wrote: > @line = () if /^DATE:/; ## set array @line to an empty list if line begin > DATE? Yes, this will clear out the previous record. > push @line, $_; ## then push the value of line to an empty @line array? @line is empty only if this is the first

Re: Extracting a Range of Lines

2006-06-04 Thread joseph
""Mr. Shawn H. Corey"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 2006-05-06 at 08:51 +0800, joseph wrote: >> Hello List, >> >> I need help in extracting a range of lines from a log files, i tried to >> do &

Re: Extracting a Range of Lines

2006-06-04 Thread Mr. Shawn H. Corey
On Mon, 2006-05-06 at 08:51 +0800, joseph wrote: > Hello List, > > I need help in extracting a range of lines from a log files, i tried to do > it with this script: > > > #!/bin/perl > > use strict; > use warnings; > > open(FILE,"/home/teragram/stat

Extracting a Range of Lines

2006-06-04 Thread joseph
Hello List, I need help in extracting a range of lines from a log files, i tried to do it with this script: #!/bin/perl use strict; use warnings; open(FILE,"/home/teragram/status_log.txt") or die "can't open file $!\n"; my @line; while () { if (/DAT

Re: problems extracting a range of lines, reworked

2003-03-14 Thread R. Joseph Newton
Pam Derks wrote: > the program ran as expected > but I did get this error: > Use of uninitialized value at instr_guts.pl line 39, chunk 2. > > here's line 39: > 39if($replace =~ $1){ > .. > here's the sample output: > YES: C. J. S. WALLIA > 1: Instructor: C. J. S. WALLIA > > 2: C. J

Re: problems extracting a range of lines, reworked

2003-03-14 Thread Pam Derks
the program ran as expected but I did get this error: Use of uninitialized value at instr_guts.pl line 39, chunk 2. here's line 39: 39if($replace =~ $1){ one thing I forgot to mention, at the end of every instructor bio in , I added "XXX", so I could mark the end bio. here's the

Re: problems extracting a range of lines, reworked

2003-03-14 Thread Pam Derks
thanks for help, here's my solution, any further comments are welcomed... thanks, Pam #!/usr/bin/perl -w use strict; #Purpose: replace Instructor: Name with bio from backmatter open(CAT, "catalog.txt") or die ("no IN file: $!"); open(BIOS, "instructor.txt") or die ("no instructor file: $!")

Re: problems extracting a range of lines, reworked

2003-03-13 Thread R. Joseph Newton
Pam Derks wrote: > thanks for help, here's my solution, any further comments are welcomed... > > thanks, Pam Hi Pam, What are the results from your test run? I foresee trouble beyond the first replaced instrucor name. Let me know if I am off base here. Joseph > #!/usr/bin/perl -w > use stri

Re: problems extracting a range of lines

2003-03-13 Thread R. Joseph Newton
Pam Derks wrote: > Hi all, Hi Pam, I think you may be making it harder than it needs to be. I will add some inline comments . > In FILE1 I want to replace all the lines containing: > Instructor: [A-Z].+ You are jumping far too quickly into code here. This should be in english. Are you ac

Re: RE: problems extracting a range of lines

2003-03-13 Thread Pam Derks
I have about 900 instructors and file2 is NOT in the same order as file1... I'll give the key/value approach thanks, Pam >>> "Wagner, David --- Senior Programmer Analyst --- WGO" <[EMAIL PROTECTED]> 03/13/03 >>> 08:37 AM >>> Pam, Using the +< for the re-writes won't work. I believe they need t

RE: problems extracting a range of lines

2003-03-13 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Pam, Using the +< for the re-writes won't work. I believe they need to be the same size for what you want to replace. Since you are using a name and then replacing with the name plus bio, you will need a third file to write to. How many instructors do you have? Unless file2 is the same order a

problems extracting a range of lines

2003-03-13 Thread Pam Derks
Hi all, In FILE1 I want to replace all the lines containing: Instructor: [A-Z].+ with the complete biography for each instructor in FILE2 or replace this text in FILE1 Instructor: GENE ABBOTT with this text from FILE2 GENE ABBOTT, M.A., has worked in vocational and adult education si