- 论坛徽章:
- 2
|
本帖最后由 yinyuemi 于 2012-02-22 15:52 编辑
回复 1# netherunix - #!/bin/perl
- use strict;
- use Data::Dumper;
- my (%hash,@data);
- @data = (my $s =(<DATA>)) =~ /(\w+),(\w+)/;
- while(<DATA>) {
- chomp;
- my @tmp = split /,/;
- map{push @{$hash{$data[$_]}},$tmp[$_]} (0..1);
- }
- #print Dumper \%hash;
- map{
- my $index = $_;
- print "<dataset name = '$data[$index]'>","\n";
- map{print "<set value = '$hash{$data[$index]}->[$_-1]' />","\n"} 1..@{$hash{$data[$index]}};
- print "</dataset >\n";}(0..1)
- __DATA__
- cpu_idle,Util
- 11,22
- 33,44
- 55,66
复制代码 |
|