Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
quotemeta has little to do with how Perl keeps variables internally. You need to separate those concerns to avoid confusion.

quotemeta is used to insert backslashes preceding non-word characters in a string for the purpose of avoiding regex meta-ness if that string were to be used in a regular expression.

In addition, you need to separate the concerns of how Perl keeps variables internally from how you perceive Perl strings.

Treat a Perl string as a string of characters (in the abstract sense, not in the char C sense). How each character is stored internally is a separate issue. How each character is represented (as bytes) when you print them out can be decided based on how they are encoded.

This separation of concerns allows the wonderful use of Unicode. We can rest easy knowing that each character is not limited to 256 or 65536 (or whatever) different types. We treat characters as characters - today, Perl operations like regexp matching work on characters, so do length, substr, etc.

Miss the old-think where strings were composed of just bytes? Then map the new-think of character strings back to where each character can have 256 different types (1 byte per character) and you'll have things back to the old way. Caveat: if you're taking this approach, you won't be able to represent Unicode characters from Latin Extended onwards.

Perl has no concept of NUL-terminated strings. In the example below, when we store a NUL byte as a Perl string, the string is interpreted as having a single NUL character:
use Devel::Peek; my $v = "\x{00}"; # $v is a string with a NUL character Dump $v; __END__ SV = PV(0x100801c78) at 0x1008143e8 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0x100218910 "\0"\0 CUR = 1 LEN = 8

This may be of interest: Why Not Translate Perl to C?

In reply to Re: Perl5 Internal Representation of string variable by repellent
in thread Perl5 Internal Representation of string variable by flexvault

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 meditating upon the Monastery: (4)
As of 2024-04-19 21:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found