Code:
$
$ perl -lne "if (/^spawn.*?\@(\w+).*$/) {\$chassis = \$1}
elsif (/^\s+blade\[(\d+)\]\s+(.*)$/) {print \"insert into blades (chassis,blade,hostname) values ('\$chassis', '\$1', '\$2');\"}
" 17da
insert into blades (chassis,blade,hostname) values ('17da', '1', 'H27995BLD');
insert into blades (chassis,blade,hostname) values ('17da', '2', 'H27995TST');
insert into blades (chassis,blade,hostname) values ('17da', '3', 'H2LABBUSMED01');
insert into blades (chassis,blade,hostname) values ('17da', '4', 'H2LABBUSMED02');
insert into blades (chassis,blade,hostname) values ('17da', '5', 'QARWDK');
insert into blades (chassis,blade,hostname) values ('17da', '6', 'QARWFK');
insert into blades (chassis,blade,hostname) values ('17da', '7', 'QARWFW');
insert into blades (chassis,blade,hostname) values ('17da', '8', 'QARWDP');
insert into blades (chassis,blade,hostname) values ('17da', '9', 'QARWDD');
insert into blades (chassis,blade,hostname) values ('17da', '10', 'QARWDN');
insert into blades (chassis,blade,hostname) values ('17da', '11', 'H2ABLE01');
insert into blades (chassis,blade,hostname) values ('17da', '12', 'H2ABLE02');
insert into blades (chassis,blade,hostname) values ('17da', '13', 'H2ABLE03');
insert into blades (chassis,blade,hostname) values ('17da', '14', 'H2ABLE04');
$
$