#!/usr/bin/env perl
use 5.010;
while ($_=<DATA>) {
if (/^name \w+/){
say $&; # 比對到的字串
$_ = <DATA>;
@specs = split;
shift @specs;
$_ = <DATA>;
@value = split;
say "spec $_\nvalue ", $value[1] for @specs;
say "";
}
}
__DATA__
name a1b1c1
spec aaa1 bbb1 ccc1
value 500
name a2bc
spec aaa2
value 600
name ab2c
spec bbb2
value 550
name d3e3
spec ddd3 eee3
value 230