<p>I have a text file with multiple records. I want to search a name and date, for example if I typed <code>JULIUS CESAR</code> as name then the whole data about <code>JULIUS</code> will be extracted. What if I want only to extract information?</p>

<pre><code>Record number: 1
Date: 08-Oct-08
Time: 23:45:01
Name: JULIUS CESAR
Address: BAGUIO CITY, Philippines
Information:
I lived in Peza Loakan, Bagiou City
A Computer Engineering student
An OJT at TIPI.
23 years old.

Record number: 2
Date: 09-Oct-08
Time: 23:45:01
Name: JOHN Castro
Address: BAGUIO CITY, Philippines
Information:
I lived in Peza Loakan, Bagiou City
A Electronics Comm. Engineering Student at SLU.
An OJT at TIPI.
My Hobby is Programming.


Record number: 3
Date: 08-Oct-08
Time: 23:45:01
Name: CESAR JOSE
Address: BAGUIO CITY, Philippines
Information:
Hi,,
I lived Manila City
A Computer Engineering student
Working at TIPI.
</code></pre>

If it is one line per entry, you could use a regular expression such as:
```
```
$name = "JULIUS CESAR";
```
```
Then use:
```
```
/$name/i
```
```
to test if each line is about "JULIUS CESAR." Then you simply have to use the following regex to extract the information (once you find the line):
```
```
/Record number: (\d+) Date: (\d+)-(\w+)-(\d+) Time: (\d+):(\d+):(\d+) Name: $name Address: ([\w\s]+), ([\w\s]+?) Information: (.+?)$/i
```
```
$1 = record number
$2-$4 = date
$5-$7 = time
$6 = address
$7 = comments
I would write a code example, but my perl is rusty. I hope this helps :)