抛个砖:- my $raw = '{1., 352400.11}, {9., 348500.91}, {15., 349000.76}, {21., 348800.83}, {29., 330900.75}, {37., 327100.03}, {45., 328300.43}, {49., 321300.33}, {51., 322500.64}, {62., 306700.}, {74., 314600.}';
- my @d = eval "($raw)"=~tr/{}/[]/r;
- printf "data 1: %s\n", join( ", ", map { sprintf "%d -> %d", $_+1, $d[$_][0] } ( 0 .. $#d) );
- printf "data 2: %s\n", join( ", ", map { sprintf "%d -> %d", $_+1, $d[$_][1] } ( 0 .. $#d) );
复制代码 脚本语言: perl
输出
data 1: 1 -> 1, 2 -> 9, 3 -> 15, 4 -> 21, 5 -> 29, 6 -> 37, 7 -> 45, 8 -> 49, 9 -> 51, 10 -> 62, 11 -> 74
data 2: 1 -> 352400, 2 -> 348500, 3 -> 349000, 4 -> 348800, 5 -> 330900, 6 -> 327100, 7 -> 328300, 8 -> 321300, 9 -> 322500, 10 -> 306700, 11 -> 314600 |