Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Readonly oddity

by ww (Archbishop)
on Jan 26, 2016 at 13:16 UTC ( [id://1153668]=note: print w/replies, xml ) Need Help??


in reply to Readonly oddity

Your systax does NOT match that which is documented for 1.03 & 2.00:

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

Version 1.03 is very old: From CPAN: "This documentation describes version 1.03 of Readonly.pm, April 20, 2004). " The more recent version is 2.00 (with a different maintainer) and a copyright date of "2013-2014." (And that doesn't begin to address the archaic versions of Perl you mention -- 5.14 and, even more so, 5.02... which, if correct makes the "aside" below relevant).)

Aside; unknown relevance but perhaps of interest from the 2.00 doc:

Please note that most users of Readonly no longer need to install the companion module Readonly::XS which is recommended but not required for perl 5.6.x and under. Please do not force it as a requirement in new code and do not use the package variable $Readonly::XSokay in code/tests. For more, see "Internals" in the section on Readonly's new internals.

Updated markup and s/"The version you're using.../"Version 1.03...."/p>

Replies are listed 'Best First'.
Re^2: Readonly oddity
by hippo (Bishop) on Jan 26, 2016 at 13:38 UTC
    the archaic versions of Perl you mention -- 5.14 and, even more so, 5.02

    I think you've misread the latter. The OP refers to "5.020003" which is 5.20.3 when the leading zeroes are omitted.

Re^2: Readonly oddity
by Mr. Muskrat (Canon) on Jan 26, 2016 at 16:09 UTC

    The Synopsis for Readonly 1.03 and 2.00 do in fact show this form:

    # 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, ...);
    Readonly-1.03 Readonly-2.00

      I think the OP knows the correct way to use the module, the point is that when it is used incorrectly it throws an error in v1.3 but doesn't in v2.0

        It was a reply to ww, not the OP, because he said it wasn't documented that way.

        Thanks for playing though. Enjoy your parting gift.

Re^2: Readonly oddity
by mr_ron (Chaplain) on Jan 26, 2016 at 14:20 UTC

    I just changed:

    Readonly my $foo = 'bar'; Readonly my @baz = (qw/glug argh/);

    to:

    Readonly my $foo => 'bar'; Readonly my @baz => (qw/glug argh/);
    And got fine output.

    I would ask the initial "Anonymous Monk" poster to please read "perldoc Readonly" a bit more carefully. Thx.

    As choroba noted the post did not do a good job of answering the question and the comment with a strike through it was not appropriate. I have taken some time and effort to research the question more carefully and have put some insights that I still feel may be useful in a new separate post in this thread.

    Ron
      I would ask the initial "Anonymous Monk" poster to please read "perldoc Readonly" a bit more carefully. Thx.
      I'd ask you to please read the OP a bit more carefully. Thx.
      You might have noticed that the script above is subtly broken. I should have written Readonly my $foo => 'bar'
      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1153668]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-26 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found