Hello,
the slices of hashes work strangely ...
The parts 1, 2 and 4 work fine; but the part 3 doesn't do what I expect.
What is wrong in what I do in part 3 ?
#!/usr/bin/perl
#slice3.pl
use warnings;
use strict;
# 1
my %h1 = (a => 1, b => 2, c => 3, d => 4, e => 5, f => 6);
print sort {$a <=> $b} map {$h1{$_}." "} keys %h1;
print "\n";
print " ", map{ $_." " } @h1{'b'..'e'};
print "\n";
@h1{'b'..'e'} = (20, 30, 40, 50);
print " ", map{ $_." " } @h1{'b'..'e'};
print "\n";
print "="x13, "\n";
# 2
my %h3;
@h3{"Foo", "Bar", "Mamadoo", "Toto", "Lulu", "Momo"} = (1, 2, 3, 4, 5, 6);
print map {$_." "} values %h3;
print "\n";
print "~"x13, "\n";
# 3
@h3{"Mamadoo".."Lulu"} = (30, 40, 50 );
print map {$_." "} values %h3;
print "\n";
print "~"x13, "\n";
# 4
@h3{"Mamadoo","Lulu"} = (30, 50);
print map {$_." "} values %h3;
print "\n";
tia
PS
if I write:
@h3{"Mamadoo".."Lulu"} = (30, 40, 50 );
the script hangs (no error is displayed)
--
Gérard
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>