>> > clamp %hash, 0 >> > clamp %hash, 1 >> unclamp %hash; >> clamp %hash; > >Which would make Jeffrey's other example very tedious: > > my $prev = clamp %$ref, 0; > $ref->{NewKey} = 1; > clamp %$ref, $prev; >=> > my $prev = clamped %$ref; > unclamp %$ref; > $ref->{NewKey} = 1; > $prev and clamp %$ref; Hmm.. if "clamp" and "unclamp" return a reference to the supplied hash, one could have: my $prev = clamped %$ref; (unclamp %$ref)->{NewKey} = 1; clamp %$ref if $prev; The "if" instead of "and" looks more natural, doesn't it? You could add parens if you worry about precedence problems. Of course, it's pretty unnatural to pass in a hash, and return a reference to that hash. Returning the hash itself from "unclamp" leads to, err... (\unclamp %$ref)->{NewKey} = 1; I don't know, I must be overlooking a better way... Craig Milo RogersThread Previous | Thread Next