for my $pd (sort {$a<=>$b} keys %x_data){ push @x_legend,$period[$pd];