in reply to Re: Percentages to Fractions
in thread Percentages to Fractions

sub fract { %_=(%_,$_[0],$%); ~~%_ }

This is bogus. $% is a built-in variable meaning "the current page number of the output." You could also write it as $_{$_[0]} = 1; which has a similar effect on the contents of the %_ hash.

The ~~%_ is the same as scalar(%_) because the ~ is the bitwise not. A hash in scalar context becomes a string representing the fraction of used hash buckets over the unused buckets.

Replies are listed 'Best First'.
Re: Re: Re: Percentages to Fractions
by ihb (Deacon) on Apr 13, 2004 at 00:30 UTC

    The $% just there for obfuscation, it could've been mostly any scalar -- that it's a built-in makes no difference -- as you indicated. However, "recent" optimizations involving shared values between keys makes it not generate the wanted result since the value is constant. For that, different values would be preferable, e.g. $_{$_[0]} = keys %_;.

    Not that anyone ever should even think about using this.

    ihb