develooper Front page | perl.beginners | Postings from March 2002

Re: Search for a word in between words

Thread Previous | Thread Next
From:
John W. Krahn
Date:
March 27, 2002 11:23
Subject:
Re: Search for a word in between words
Message ID:
3CA21BF3.9D65E3B4@acm.org
Allison Ogle wrote:
> 
> To give you even more information, in my datafile, the word that I am
> searching for is 'marked' by the word in the line before it.  For example,
> the lines in my datafile look like..
> 
> line 1
> line 2
> line 2
> Installation
> example
> Installation
> line 4
> line 5
> line 6
> 
> and all I want is the word in between the words Installation.  Because I
> don't know what the word in between the words Installation will be, I'm not
> actually searching for the word Installation but for the word in the next
> line after Installation.  Does that make sense?  Any ideas?


while ( <FILE> ) {
    chomp;
    if ( /^Installation$/ ) {
        my $word = <FILE>;
        print "$word\n";
        last;
        }
    }


John
-- 
use Perl;
program
fulfillment

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About