Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I am not quite sure why it is said above that type coercion is going to cause a problem here. Let me provide a little example.
use ExtUtils::testlib; use Flag; #all local, sorry my $c = 'test'; Flag::sv_set_flag($c, 'READONLY'); #$c++; #$c = 'not a test'; $c = 5;
Any of those examples produce a "Modification of a read-only value" error. Naturally. And as long as that works, that we cannot directly modify the value, we're set. Certain types of behavior can modify the underlying data structure, but not to the point of changing the eventual data.
use Devel::Peek; use ExtUtils::testlib; use Flag; my $c = 15; Flag::sv_set_flag($c, 'READONLY'); print Dump $c; print "$c"; print Dump $c;
Naturally the interpolation causes the IV to become an PVIV. But our PV value will be "15"\0. So in any circumstance our behavior is normal. Yes the structure has changed, but from a user standpoint our data is readonly.

Is there a specific need to protect the data from perl internals that could possibly be ignoring the readonly state of a variable? If not, then type coercion isn't a problem at all.


In reply to Re: Reliability of SvREADONLY by zshzn
in thread Reliability of SvREADONLY by hardburn

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-03-28 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found