Greping the required parameter...

Hi Friends,
Urgently required to know this :

I have a file which has several stanzas like below :
CuDv:
name = "hdisk3"
status = 1
chgstatus = 2
ddins = "scdisk"
location = "03-08-01-11,0"
parent = "scsi1"
connwhere = "11,0"
PdDvLn = "disk/scsi/scsd"

CuDv:
name = "hdisk2"
status = 1
chgstatus = 2
ddins = "scdisk"
location = "03-08-01-11,0"
parent = "scsi0"
connwhere = "11,0"
PdDvLn = "disk/scsi/scsd"

My question is : How can one get the field specified in the"name"( In this case hdisk3 of 1st stanza) if "parent=scsi1" ?

Thanks is advance..

Pedestrian solution: awk script to remember the name it has seen last, and print it when it sees the right parent. Forget the previous name when you see an empty line.

Slightly more advanced: perl has a way to read multiple lines; if you know the basics of the language, looking for $/ in examples and in the FAQ should be enough for you.

Enterprise solution: hire an incompetent consultant to write 67 Java classes which altogether fail to correctly parse this file format.

awk 'BEGIN{FS="="}
/name =/ { d=$2 }
/parent = \"scsi1\"/ { print d}
' file
nawk 'BEGIN{FS="";RS="CuDv:"}
{
if(index($7,"scsi0")!=0)
print substr($2,index($2,"\"")+1,length($2)-index($2,"\"")-1)
}' filename