Seach for a string following a particular string in a file

All,
I have a file like ;

...  covers bhjl;
...  khkjhk..  covers vjgj;
.. bvjhy.. bkhk..  covers bjhk;

Now I want to search all strings that follows covers and then write them in a new file. I want to use perl script for that.

Output file should conatian:

bhjl
vjgj
bjhk

Regards
Anamika

does "cover" always appear once per line ?
does "cover" always appear before the last word of the line ?

yes..it will appear one in a line.

---------- Post updated at 04:33 AM ---------- Previous update was at 04:29 AM ----------

yes..it will appear once in a line and it will come just before the last word of that line. But there can be other lines that does not conatin cover. I do not have to do anything with them.

Are you willing to also remove the ending semicolon ";" for the lines containing "cover" ?

Yes.. It should be removed. I need only the word next to cover.

sed '/cover/s/[ ]*;$//;s/.*cover //' yourfile 

Will it work for perl.. I want in perl...

---------- Post updated at 05:09 AM ---------- Previous update was at 05:07 AM ----------

Will it work for perl ???I want to run for perl in windows....

If you are under windows, i suggest you get the sourceforge GNU unix tools compiled for windows.
unzip them into a Directory of your choice and add that directory in your PATH environement variable.
You will then be able to use gawk as well as sed one of the very few thing that will change is the use of doublequote istead of simple quote.

In a DOS windows: example to display the second column of a csv file that is coma separated :

gawk -F, "{print $2}" yourfile.csv

try like this in perl:

run as follows:
perl try.pl input_file

while(<>) {
print "$1\n" if /(?<=covers) (\w*);$/;
}
cat input_file
...  covers bhjl;
...  khkjhk..  covers vjgj;
.. bvjhy.. bkhk..  covers bjhk;
output:
bhjl
vjgj
bjhk

you can also try from commandline:

perl -ne 'print "$1\n" if /(?<=covers) (\w*);$/;' input_file

Change the regex as per your need.