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;

posted @ 2013-01-17 09:59  Arya_yu  阅读(368)  评论(0编辑  收藏  举报