Animator's text gave me inspiration to go create a tied hash module just for the learning experience.
Included below.
### BEGIN OF tie_rounded_hash MODULE require 5.005; use strict; #use warnings; #use diagnostics -verbose; package tie_rounded_hash; BEGIN { use Carp; use Exporter (); our (@ISA, @EXPORT_OK, @EXPORT); our $VERSION = '1.0'; @ISA = qw(Exporter); @EXPORT = qw(); @EXPORT_OK = qw(); } our %Rounded = (); our %List = (); our @EXPORT_OK; #sub TIEHASH { bless \%List, $_[0] } #sub FETCH { $_[0]->{$_[1]} } sub STORE { $List{$_[1]} = $_[2] } sub FIRSTKEY { my $a = scalar keys %List; each %List } sub NEXTKEY { each %List } sub EXISTS { exists $List{$_[1]} } sub DELETE { delete $List{$_[1]} } sub CLEAR { %List = () } sub TIEHASH { my $self = shift; my $rounded = shift || 0; # rounded is the number of digits to leave to the right of the decimal + point. croak "usage: $self <#of_digits>" if @_; bless {Rounded => $rounded, LIST => \%List}, $self; } sub FETCH { my $self = shift; my $key = shift; if ($self->{Rounded}) { return sprintf("%1.*f",$self->{Rounded},$List{$key}); } else { return $List{$key}; } } 1; ### END of module ### example script use strict; use lib qw(.); use tie_rounded_hash; my %test; my %rounded; tie %test, 'tie_rounded_hash',0; tie %rounded,'tie_rounded_hash',2; for (1..100) { $test{$_} = $^T/$_; } for (1..100) { print "$_ => $test{$_}\t $rounded{$_}\n"; }

In reply to Re^2: rounding off all members of a hash by Keystroke
in thread rounding off all members of a hash by vindaloo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.