Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Readonly 1.03

    Download button

    No screenshots available
    Downloads: 383  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Eric J. Roode | More programs
    Perl Artistic License / FREE
    May 21st, 2007, 22:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Readonly description

    Readonly is a Perl module that offers the facility for creating read-only scalars, arrays, hashes.

    Readonly is a Perl module that offers the facility for creating read-only scalars, arrays, hashes.

    SYNOPSIS

    use Readonly;

    # Read-only scalar
    Readonly::Scalar $sca => $initial_value;
    Readonly::Scalar my $sca => $initial_value;

    # Read-only array
    Readonly::Array @arr => @values;
    Readonly::Array my @arr => @values;

    # Read-only hash
    Readonly::Hash %has => (key => value, key => value, ...);
    Readonly::Hash my %has => (key => value, key => value, ...);
    # or:
    Readonly::Hash %has => {key => value, key => value, ...};

    # You can use the read-only variables like any regular variables:
    print $sca;
    $something = $sca + $arr[2];
    next if $has{$some_key};

    # But if you try to modify a value, your program will die:
    $sca = 7;
    push @arr, 'seven';
    delete $has{key};
    # The error message is "Modification of a read-only value
    attempted"

    # Alternate form (Perl 5.8 and later)
    Readonly $sca => $initial_value;
    Readonly my $sca => $initial_value;
    Readonly @arr => @values;
    Readonly my @arr => @values;
    Readonly %has => (key => value, key => value, ...);
    Readonly my %has => (key => value, key => value, ...);
    # Alternate form (for Perls earlier than v5.8)
    Readonly $sca => $initial_value;
    Readonly my $sca => $initial_value;
    Readonly @arr => @values;
    Readonly my @arr => @values;
    Readonly %has => (key => value, key => value, ...);
    Readonly my %has => (key => value, key => value, ...);

    This is a facility for creating non-modifiable variables. This is useful for configuration files, headers, etc. It can also be useful as a development and debugging tool, for catching updates to variables that should not be changed.
    If any of the values you pass to Scalar, Array, or Hash are references, then those functions recurse over the data structures, marking everything as Readonly. Usually, this is what you want: the entire structure nonmodifiable. If you want only the top level to be Readonly, use the alternate Scalar1, Array1 and Hash1 functions.

    Please note that most users of Readonly will also want to install a companion module Readonly::XS. See the "CONS" section below for more details.

    Requirements:

    · Perl 5.000
    · Carp.pm (included with Perl)
    · Exporter.pm (included with Perl)



    Product's homepage

    Requirements:

    · Perl 5.000
    · Carp.pm (included with Perl)
    · Exporter.pm (included with Perl)

      


    TAGS:

    read-only scalars | create arrays | create hashes | Readonly | read-only | scalars

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM