MAJOR=1
MINOR=8
DEVNAME=random
DEVMODE=0666
  A   ˆl–Ãa¾”ËmJq@»pÜi¥1hß�þ\+l¬Û-W›p¯� þÀ„ÂiŸÅ_ˆI|¥�+V[(ÄÃ ?÷     package Readonly;
use 5.005;
use strict;

#use warnings;
#no warnings 'uninitialized';
package Readonly;
our $VERSION = '2.05';
$VERSION = eval $VERSION;

# Autocroak (Thanks, MJD)
# Only load Carp.pm if module is croaking.
sub croak {
    require Carp;
    goto &Carp::croak;
}

# These functions may be overridden by Readonly::XS, if installed.
use vars qw/$XSokay/;    # Set to true in Readonly::XS, if available

# Predeclare the following, so we can use them recursively
sub _ARRAY (\@);
sub _HASH (\%);

# For perl 5.8.x or higher
# These functions are exposed in perl 5.8.x (Thanks, Leon!)
# They may be overridden by Readonly::XS, if installed on old perl versions
if ($] < 5.008) {    # 'Classic' perl
    *is_sv_readonly = sub ($) {0};
    *make_sv_readonly
        = sub ($) { die "make_sv_readonly called but not overridden" };

    # See if we can use the XS stuff.
    $Readonly::XS::MAGIC_COOKIE = $Readonly::XS::MAGIC_COOKIE
        = "Do NOT use or require Readonly::XS unless you're me.";
    eval 'use Readonly::XS';
}
else {               # Modern perl doesn't need Readonly::XS
    *is_sv_readonly = sub ($) { Internals::SvREADONLY($_[0]) };
    *make_sv_readonly
        = sub ($) { Internals::SvREADONLY($_[0], 1) };
    $XSokay = 1;     # We're using the new built-ins so this is a white lie
}

# Undo setting readonly
sub _SCALAR ($) {
    my ($r_var) = @_;
    if ($XSokay) {
        Internals::SvREADONLY($r_var, 0) if is_sv_readonly($r_var);
    }
    else {
        return if tied($r_var) !~ 'Readonly::Scalar';
        my $r_scalar;
        {
            my $obj = tied $$r_var;
            $r_scalar = $obj;
        }
        untie $r_var;
        $r_var = $r_scalar;
    }
}

sub _ARRAY (\@) {
    my ($r_var) = @_;
    return if !tied(@$r_var);
    return if tied(@$r_var) !~ 'Readonly::Array';
    my $r_array;
    {
        my $obj = tied @$r_var;
        $r_array = $obj;
    }
    untie @$r_var;
    @$r_var = @$r_array;

    # Recursively check child elements for references; clean if Readonly
    foreach (@$r_var) {
        my $_reftype = ref $_;
        if ($_reftype eq 'SCALAR') { _SCALAR($_) }
        elsif ($_reftype eq 'ARRAY') {
            _ARRAY(@$_);
        }
        elsif ($_reftype eq 'HASH') {
            _HASH(%$_);
        }
    }
}

sub _HASH (\%) {
    my ($r_var) = @_;
    return if !tied(%$r_var);
    return if tied(%$r_var) !~ 'Readonly::Hash';
    my $r_hash;
    {
        my $obj = tied %$r_var;
        $r_hash = $obj;
    }
    untie %$r_var;
    %$r_var = %$r_hash;

    # Recursively check child elements for references; clean if Readonly
    foreach (values %$r_var) {
        my $_reftype = ref $_;
        if ($_reftype eq 'SCALAR') { _SCALAR($_) }
        elsif ($_reftype eq 'ARRAY') {
            _ARRAY(@$_);
        }
        elsif ($_reftype eq 'HASH') {
            _HASH(%$_);
        }
    }
}

# Common error messages, or portions thereof
use vars qw/$MODIFY $REASSIGN $ODDHASH/;
$MODIFY   = 'Modification of a read-only value attempted';
$REASSIGN = 'Attempt to reassign a readonly';
$ODDHASH  = 'May not store an odd number of values in a hash';

# ----------------
# Read-only scalars
# ----------------
package Readonly::Scalar;

sub STORABLE_freeze {
    my ($self, $cloning) = @_;
    Readonly::_SCALAR($$self) if $cloning;
}

sub TIESCALAR {
    my $whence
        = (caller 2)[3];    # Check if naughty user is trying to tie directly.
    Readonly::croak "Invalid tie"
        unless $whence && $whence =~ /^Readonly::(?:Scalar1?|Readonly)$/;
    my $class = shift;
    Readonly::croak "No value specified for readonly scalar" unless @_;
    Readonly::croak "Too many values specified for readonly scalar"
        unless @_ == 1;
    my $value = shift;
    return bless \$value, $class;
}

sub FETCH {
    my $self = shift;
    return $$self;
}
*STORE = *STORE = sub { Readonly::croak $Readonly::MODIFY };
*UNTIE = *UNTIE
    = sub { Readonly::croak $Readonly::MODIFY if call