Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Well yes that's how it's implemented in Perl - and other languages like Python or JS too - but doesn't help comparing languages.

They all store references into their "namespaces" or "lexical pads"

...

and anonymous" only refers to the literal array or {hash} constructors not to the scalar on the LHS of an assignment.

perldata states:

Values are usually referred to by name, or through a named reference.

So the LHS in $ary = [1,2,3] is a named reference; it is a named variable. The RHS is an anonymous array, at least that is what is called throughout the perl documentation. So let's stick to that to avoid confusion.

The difference is not "named" or "unnamed", but explicit or implicit dereferencing.

Difference between languages, but not in perl.

In perl, the scalar $ary may hold an anonymous array. But @ary is a named array. Perl does no implicit derefrencing, and so the syntax to access slots of the named array @ary necessarily has to be distinct from the one to access a slot of the anonymous array stored in the named scalar variable $ary - or of any anonymous array:

my $result = [ func(@args) ]->[2];

So in perl - at least that is how I understand perl for a couple of decades now - the difference is between named and anonymous variables. To get hold of an anonymous variable beyond a single statement, its reference has to be stored in a named scalar variable.

But I'm not going on telling you stuff you know as well as I do, only to get reverse 'halb' back, and I won't argue any more, since there is no point but frustration. Let's close this sub-thread. Thank you.

update

°) or scalars, but this can't be easily written *scalar = \1 is not the same thing

Of course not, because that makes a reference from a constant. A variable reference is needed to make it variable:

*scalar = \do { my $x = 1 };

The expression *scalar = \"foo bar" creates a package constant (readonly package variable) $scalar (but *scalar = \"Hello $world" doesn't, it's r/w :-).

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

In reply to Re^10: Thx, St. Larry, for the Beauty of Sigils by shmem
in thread Thx, St. Larry, for the Beauty of Sigils by msouth

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 imbibing at the Monastery: (7)
As of 2024-03-28 19:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found