ponh 发表于 2015-12-27 09:31:02

perl hash 切片

  #!/usr/bin/perl -w
use strict;
use YAML::XS;
  my %hash;
my %new;
  @hash{'a' .. 'm'} = 1 .. 13;
@new{ 'n' .. 'z' } = 14 .. 26;
print "Before change\n";
map{ print "$_ => $hash{$_}\n"} sort keys %hash;
  @hash{ keys %new } = values %new;
  print "After change\n";
map{ print "$_ => $hash{$_}\n"} sort keys %hash;
页: [1]
查看完整版本: perl hash 切片