Michael Stearman wrote:
> 
> Hi!

Hello,

> I have a hash and I want to set all the values equal to zero.  I want to
> keep the keys as they are though.  Anyone know how?

Here is one way to do it:

$ perl -le'
my %hash = (
    a => int(rand 999)+1, b => int(rand 999)+1,
    c => int(rand 999)+1, d => int(rand 999)+1,
    e => int(rand 999)+1, f => int(rand 999)+1,
    g => int(rand 999)+1, h => int(rand 999)+1,
    );
print "@{[%hash]}";

@hash{keys %hash} = (0) x keys %hash;
print "@{[%hash]}";
'
a 991 b 784 c 620 d 984 e 452 f 547 g 676 h 141
a 0 b 0 c 0 d 0 e 0 f 0 g 0 h 0



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to