# example of constant: # use constant TMPDIR = '/bigdrive/bigbucket01'; use constant TMPDIR = '/tmp'; # /tmp now mapped to above # example of Readonly: sub Write { my $self = shift; Readonly my %reset = %$self; # ... code that modifies $self # e.g. with 'dangerous' use of eval ... $self -> ( STATE } = eval $self -> { COMMAND } or goto ERROR; # ... $self -> Close() and return 1; # if error reset $self: ERROR: delete $self -> { $_} for keys %$self; $self -> { $_ } = $reset{ $_ } for keys %reset; return 0; }